I am making a page that displays links and the previous / next in my own special way and its turning out to be not so special if I can't figure this problem out. After the code executes, it displays the 1st link, a blank row, and then the 3rd link, then doesn't display anything past 3. And I have 5 links in the database.
if(isset($id))
{
// get all the links with the query
$Query = mysql_query("SELECT * FROM $TableName WHERE link_category='$id' ORDER BY link_date");
//get the number of links in DB
$Query_count = mysql_query("SELECT count(*) FROM $TableName WHERE link_category='$id'") or die(mysql_error());
if(!isset($where))
{
$i=1;
} else {
$i = $where;
}
for ($i=$i; $i<$Query_count; $i++)
{
$row = mysql_fetch_array($Query,$i) or die(mysql_error());
echo("
<tr>
<td width=\"43%\" background=\"Page_Images/text_background.jpg\" align=\"center\"><a href=\"links.php?go=".urlencode($row["link_id"])."\"><font color=\"#00FF99\">$row[link_name]</font></a></td>
<td width=\"10%\" align=\"center\"><font color=\"#FFFF66\">$row[link_hits]</font></td>
");
$More_info_link = ("links.php?" . $row["link_id"]);
echo("
<td width=\"4%\" align=\"center\"><a href=$More_info_link><a href=\"links.php?info=".urlencode($row["link_id"])."\">&</a></td>
<td width=\"43%\" background=\"Page_Images/text_background_rev.jpg\" align=\"center\">$row[link_short_description]</td>
</tr>
");
}
}
echo'</table>';
I also get the errors "Undefined index: link_id in... " in each spot where I refference $row[whateverhere]. I think maybe the one query that selects all the info before the looping can't do what I ask and hold all the info and let my fecth array in the loop access each row on each pass, but I don't get why my code would display it correctly the first time, blank the second, 3rd correct, and after 3rd nothing. If anyone could help I would really appreciate it.
Thank you.