Jabop Posted June 13, 2008 Share Posted June 13, 2008 Here is my code... <? $x=0; if ($ImageCount>0) { while(list($FileID,$Title,$FileName,$Ext,$Views)=$DB->next_record()) { if ($Title=="Untitled") { $Title=$FileName.".".$Ext; } ?> <td class="cellborder" width="50%"> blah </td> <? if ($x%2) { ?> </tr> <tr> <? } $x++; } //while ?> basically that creates a table, with two cells per row. However, on some results, the tables break, and the cells get pushed everywhere. What would be the best way for EVERY TWO cells, to produce a new TR? This is very frustrating, someone please help Link to comment https://forums.phpfreaks.com/topic/110014-the-best-way-to-use-modulus-when-trying-to-do-new-rows/ Share on other sites More sharing options...
bluejay002 Posted June 13, 2008 Share Posted June 13, 2008 i dont know if this would work (since i feel really lazy right now, sorry) but might just do the trick: <? $x = 0; if($ImageCount > 0) { while(list($FileID, $Title, $FileName, $Ext, $Views) = $DB->next_record()) { if($Title == "Untitled") { $Title = $FileName . "." . $Ext; } echo "<td class='cellborder' width='50%'>blah</td>"; if ($x % 2 == 1) { echo "</tr><tr>"; } $x++; } //while ?> i just arranged a bit the code... also the if, i changed to $x % 2 == 1 from $x % 2. i dont but just try... eheh Link to comment https://forums.phpfreaks.com/topic/110014-the-best-way-to-use-modulus-when-trying-to-do-new-rows/#findComment-564541 Share on other sites More sharing options...
Jabop Posted June 13, 2008 Author Share Posted June 13, 2008 Blah, that didn't work. some rows only get one cell per row :\ Here is an image example Some queries from the DB appear like this, some appear perfectly fine. $x is never modified (it's always 0-11), the query only selects 12 records each time, no matter what. I can't figure out what the problem is here! http://img170.imageshack.us/img170/6506/ssmissinghg4.jpg Link to comment https://forums.phpfreaks.com/topic/110014-the-best-way-to-use-modulus-when-trying-to-do-new-rows/#findComment-564606 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.