I have produced a result from the following query as shown below.Now the result I got is an array in which all the results are stored according to ‘portfolio_id’… I need to print different array of results for different portfolio_id. How is it possible?
For example when portfolio_id is 1 it will produce a frame of 9images ,portfolio_id is 18 it must produce another frame of 9 images…
$portfolio_item_query=$ilance->db->query("SELECT * FROM " . DB_PREFIX . "portfolio AS p,
" . DB_PREFIX . "portfolio_images AS pi,
" . DB_PREFIX . "users AS u,
" . DB_PREFIX . "subscription_user AS su,
" . DB_PREFIX . "portfolio_items AS it
WHERE p.portfolio_id = it.portfolio_id
AND u.user_id = p.user_id
AND it.id = pi.portfolio_item_id
AND it.portfolio_id='".$portfolio['portfolio_id']."'
GROUP BY it.id ORDER BY it.id ASC LIMIT 0,9");
$num_rows=$ilance->db->num_rows($portfolio_item_query);
if ($num_rows > 0)
{
while ($portfolio_item = $ilance->db->fetch_array($portfolio_item_query))
{
$portfolio_html.='<li><img height="57" width="57" src="images/portfolio_uploads/orig_'.$portfolio_item['image'].'"></a></li>';
}
echo $portfolio_html;
}
You could loop through the entire data set, keeping track of the
portfolio_idof each row. Then, each time theportfoio_idchanges, start a new list.If I’m understanding correctly, this should help. Here’s how you could separate a generic set of images into different unordered lists using
group_idto define groups:The table looks like this:
And the output of the above program looks like this: