php - Echo category name once per id -


i have query select id, title, imagename cat join images on id=id want echo once title per category , 3 images. , same next category.

tables layout:

cat table id title  images table id imagename 

the final result should this:

title  imagename imagename imagename  title  imagename imagename imagename 

the query printed using foreach cycle object ($this->results $result ) { echo $result->title; } etc..

also i'm interested if there other ways (queries?) of getting same results.

you need keep track of current title , echo title when different current one:

$title = ''; // loop   ...   if ($result->title !== $title)   {     echo $result->title;     $title = $result->title;   }   ... // end loop 

note need order title in query same title again later on if don't.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -