jaxdevil Posted May 26, 2008 Share Posted May 26, 2008 Below is the entire code I am using. It works like gangbusters but it always displays one extra row than there is, so a blank row comes up. How do I get rid of that? I also notice there is a $multiple variable in there but have no idea what that is for. Someone on here made this code and it has always been there, but it can't be doing anything good as an unregistered variable, can it? Maybe thats why it is displaying one more row than the query brings up? Any help is greatly appreciated. I have been up and working on this project since 8am yesterday. I am exhausted. <table width="215" cellpadding="0" cellspacing="0" border="0"> <tr> <td width="215" height="14" background="images/menu_top.gif"> </td> </tr> <?php $sql = "SELECT DISTINCT `cats` FROM products ORDER BY `cats`" or die ( "Query failed due to: ".mysql_error()); $query = mysql_query($sql); $seen = array(); while($row = mysql_fetch_array($query)) { $cats = explode("|",$row['cats']); $main_cat = $cats[0]; if(!in_array($main_cat,$seen) && !in_array($main_cat,$multiple)) { array_push($seen,$main_cat); } else { array_push($multiple,$main_cat); unset($seen[$main_cat]); } } $size = sizeof($seen); for($i=0;$i<=$size;$i++) { ?> <tr> <td width="215" height="24" background="images/menu_back.gif"> <font face="Tahoma,Verdana,Arial" color="#6e6e6e" style="font-size: 0.75em;"> <div style="padding-left: 35px;"> <a href="cats.php?cat=<?=$seen[$i]?>&subcat=1"><?=$seen[$i]?></a> </div> </td> </tr> <? } ?> <tr> <td width="215" height="6" background="images/menu_bottom.gif"> </td> </tr> </table> <img src="images/contactinfo.gif"> </td> </tr> </table> Quote Link to comment https://forums.phpfreaks.com/topic/107314-solved-extra-blank-row-displaying/ Share on other sites More sharing options...
jaxdevil Posted May 26, 2008 Author Share Posted May 26, 2008 Well it was a pretty easy fix, once I stared at it long enough..hehehe! $size = sizeof($seen)-1; for($i=0;$i<=$size;$i++) I just subtracted one from the $size variable. Problem solve.d Thank god that is over Quote Link to comment https://forums.phpfreaks.com/topic/107314-solved-extra-blank-row-displaying/#findComment-550210 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.