Jump to content

My numbered list (done with php) gets really messed up if the last number is odd


Recommended Posts

I am not sure why, but when the query (seen below) shows an odd number of tracks the entire webpage basically gets destroyed! There is alot going on on the webpages look (such as tables, css, etc.) but none of it should be causing any problems because when the query results an odd number of tracks it looks perfect. The best way to describe what happens is that the number (saying the query results 11 posts) 11 is stuck below a bunch of other things on the page. What could be wrong? I hope that makes enough since but I could never post the entire script so here is the relevant part:

 

<?php
$querytrack = "SELECT * FROM data WHERE post='$id' LIMIT 0,19";
$resulttrack = mysql_query($querytrack) or die("Couldn't execute query because: ".mysql_error());
while($rowtrack = mysql_fetch_array($resulttrack)){
   $track  = $rowtrack['track'];
   $fill2  = 1 + $fillc2++;{
if($fill2 & 1) {
?>
   <table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td bgcolor="#000000" valign="middle"><span class="style1"><?php echo $fill2; ?>.  <img src="/images/divspace.gif" height="20" /><?php if (strlen($track) > 41) $track = substr("$track", 0, 41) . "..."; print "$track"; ?></span></td></tr>
<?php
}
else {
?>
   <tr><td background="/images/resultsbg.jpg" valign="middle"><span class="style1"><?php echo $fill2; ?>.  <img src="/images/divspace.gif" height="20" /><?php if (strlen($track) > 41) $track = substr("$track", 0, 41) . "..."; print "$track"; ?></span></td></tr></table>
<?php
}
}
}
?>

why are you using bit operators? if you want to have another background color for every row i suggest you use something like

 

$row_iterator = 1;

while($rowtrack = mysql_fetch_array($resulttrack)){

echo "<tr" . (($row_iterator % 2) ? '' : ' class="odd"') . ">";

// before the end of the loop, you put

$row_iterator++;

}

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.