cmb Posted July 16, 2012 Share Posted July 16, 2012 The code is suppose to put 6 pics in a row then move to the next line. What happens is the first line only has 5 pics and all the rest have 6. How do i fix this <?php $c_query = "SELECT * FROM products WHERE Type='Candy' ORDER BY Price"; $c_results = mysql_query($c_query) or die(mysql_error()); $c = 1; while ($c_row = mysql_fetch_array($c_results)){ if($c %6 == 0){ echo "</tr><tr>"; echo "<td><center><img src='" . $c_row['Path'] . "' width='50' height='50' /></center>"; echo "<br /><center><p>" . $c_row['Product'] . " $" . $c_row['Price']. "</p></center></td>"; $c++; }else{ echo "<td><center><img src='" . $c_row['Path'] . "' width='50' height='50' /></center>"; echo "<br /><center><p>" . $c_row['Product'] . " $" . $c_row['Price']. "</p></center></td>"; $c++; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/265735-how-to-fix-this-division/ Share on other sites More sharing options...
Mahngiel Posted July 16, 2012 Share Posted July 16, 2012 because you've set $c = 1 only five will be counted before the modulus 6 is hit. 1, 2, 3, 4, 5 - 5 here 6, 7, 8, 9, 10, 11 - 6 here set $c to 0 Quote Link to comment https://forums.phpfreaks.com/topic/265735-how-to-fix-this-division/#findComment-1361801 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.