Jump to content

Recommended Posts

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>

Link to comment
https://forums.phpfreaks.com/topic/107314-solved-extra-blank-row-displaying/
Share on other sites

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.