Using: PHP, MYSQL, APACHE on WindowsXP Home Edition.
I have been working on this for a while now, but it is just not working.
The query returns 2 rows in MYSQL.
When I run this as is below, I get everything in Row 1.
In Row 2 I get no data in Row 2 (the HTML posts but is missing the results form $row). $i is 2 for Row 2.
If I move the beginning TABLE HTML block inside the For() statement, it prints the data from both rows for the first two columns, and nothing for the third and fourth. $i shows up in only the second row.
Anyone have ideas?
<html>
<body>
<?php
$session = mysql_connect ("localhost", "root");
if (!$session)
{
echo 'Error: Could not connect to the database. Please try again later.';
exit;
}
mysql_select_db('bjfn', $session);
$query = "SELECT Media.Title, CONCAT(Author.LastNm, ', ', Author.FirstNm), Media.AISN, Location.Location
FROM Media
left join Location on (Media.Location= Location.ID)
left join Author on (Media.Author = Author.ID)
";
$result = mysql_query($query);
$num_results = mysql_num_rows($result);
echo $num_results;
ECHO '<TABLE BORDER="1"><TR><TD>';
echo '<strong>Title';
ECHO '</TD>';
ECHO '<TD>';
echo 'Author';
ECHO '</TD>';
ECHO '<TD>';
echo 'AISN';
ECHO '</TD>';
ECHO '<TD>';
echo'Location</STRONG>';
ECHO '</TD>';
ECHO '</TR>';
for ($i=0; $i <$num_results+1; $i++)
{
$row = mysql_fetch_array($result);
ECHO '<TR>';
ECHO '<TD>';
echo htmlspecialchars (stripslashes($row[0]));
ECHO '</TD>';
ECHO '<TD>';
echo htmlspecialchars (stripslashes($row[1]));
ECHO '</TD>';
ECHO '<TD>';
ECHO '<a href="http://www.amazon.com/exec/obidos/ASIN/';
echo htmlspecialchars (stripslashes ($row[2]));
echo '/qid%253D1086656364/sr%253D11-1/ref%253Dsr%5F11%5F1/marksworld0c>TEST</a>';
ECHO '</TD>';
ECHO '<TD>';
echo htmlspecialchars (stripslashes ($row[3]));
echo '<td>';
echo $i; //This is here for troubleshooting only
ECHO '</TD></TR>';
}
ECHO '</TABLE>';
?>
</body>
</html>