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
Post a Comment