Hiya I have database records that are outputted in a table column for each record. I want to make it so that when every 5 records are outputted and new row is created and then another 5 column records are outputted and so on. I can't get my head around this and have attempted to create a maximum record count.
if ($productCount > 0) { while($row = mysql_fetch_array($sql4)){ $id = $row["id"]; $product_name = $row["product_name"]; $price = $row["price"]; $category = $row["category"]; $details = $row['details']; $date_added = strftime("%b %d, %Y", strtotime($row["date_added"])); $maxCount = 5; if ($productCount != $maxCount) { $dynamicList .= '<td width="150"><a href="inventory_images/'.$id.'.jpg" target="_blank"><img style="border:#666 1px solid;" src="inventory_images/' . $id . '_small.jpg" alt="' . $product_name . '" border="1" width="150"/></a> '.$details.'£'.$price.' <form id="form1" name="form1" method="post" action="cart.php"><input type="hidden" name="pid" id="pid" value='.$id.' /><input type="submit" value="" name="button" id="button" class="cardbutton" /></form></td>'; } else if ($productCount == $maxCount) { $dynamicList .= '<td width="150"><a href="inventory_images/'.$id.'.jpg" target="_blank"><img style="border:#666 1px solid;" src="inventory_images/' . $id . '_small.jpg" alt="' . $product_name . '" border="1" width="150"/></a> '.$details.'£'.$price.' <form id="form1" name="form1" method="post" action="cart.php"><input type="hidden" name="pid" id="pid" value='.$id.' /><input type="submit" value="" name="button" id="button" class="cardbutton" /></form></td></tr><tr>'; }
Needless to say it doesn't work and just outputs all the records in a single row. So I guess the else if ($productCount == $maxCount) never happens. Any ideas on how i can get this to work please?
Thank you very much.
Tom