php - Categorized gallery -


i'm trying make categorized gallery blog. far i've created datebase tables: photos (photos_id, photos_gal_id, photos_link), galeries (galeries_id, galeries_title, galeries_description), , there other tables, not related problem (such users, posts etc).

i've established connection db through init file:

<?php   class init { protected $db, $result; private $rows;  public function __construct(){     $this->db = new mysqli('localhost','root','hhpass','europa');     }  public function query ($sql){     $this->result = $this->db->query($sql);     }  public function rows(){     for($x =1; $x<= $this->db->affected_rows; $x++){         $this->rows[] = $this->result->fetch_assoc();         }         return $this->rows;     } }?> 

then data db through:

class galeries extends init { public function fetchgaleries(){      //query db     $this->query("select photos_id,                 photos.photos_gal_id 'group',                 group_concat(photos_link) link, galeries.galeries_title, galeries.galeries_description, galeries.galeries_id                 photos                 inner join galeries                 on galeries.galeries_id=photos.photos_gal_id                 group photos.photos_gal_id                  order galeries.galeries_id asc");             //return     return $this->rows();     }  } 

so far works fine.. when call function in seperate file with:

$galeries_a = new galeries(); $gals_x = $galeries_a->fetchgaleries(); 

and if use the

foreach($gals_x $gals_y){  echo $gals_y['group'];  } 

it fine , lists galeries(categories): 1,2,3,4. db-s groups, defined query.

now, problem is, how make links show inside these groups (only links belong group). know have make ul/li listings in html, , not problem, part works, problem php part :)

to sum, should this.

  • 1 first gallery
    • link one
    • link 2 etc
  • 2 second gallery
    • link one
    • link 2 etc
  • 3 third gallery
    • link one
    • link 2 etc
  • 4 fourth gallery
    • link one
    • link 2 etc

i've tried everything: while, foreach, everything, cannot work properly.


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -