spiceydog Posted July 23, 2008 Share Posted July 23, 2008 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 } } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/116281-my-numbered-list-done-with-php-gets-really-messed-up-if-the-last-number-is-odd/ Share on other sites More sharing options...
GingerRobot Posted July 23, 2008 Share Posted July 23, 2008 Well, im guessing it's to do with the presumably unclosed tables. I imagine that's screwing with your layout. Quote Link to comment https://forums.phpfreaks.com/topic/116281-my-numbered-list-done-with-php-gets-really-messed-up-if-the-last-number-is-odd/#findComment-597943 Share on other sites More sharing options...
ignace Posted July 23, 2008 Share Posted July 23, 2008 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++; } Quote Link to comment https://forums.phpfreaks.com/topic/116281-my-numbered-list-done-with-php-gets-really-messed-up-if-the-last-number-is-odd/#findComment-597946 Share on other sites More sharing options...
spiceydog Posted July 23, 2008 Author Share Posted July 23, 2008 ignace i'm not totally sure how i could do that and get it to work. I did get it to work however and the problem was because I had forgotten to end the table tag like GingerRobot said. THANK YOU!! Quote Link to comment https://forums.phpfreaks.com/topic/116281-my-numbered-list-done-with-php-gets-really-messed-up-if-the-last-number-is-odd/#findComment-598074 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.