Jump to content

The best way to use Modulus when trying to do new rows...


Jabop

Recommended Posts

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

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 :)

 

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.