I have the following snippet:
CODE
$strSQL = mysql_query("SELECT * FROM projects, clients WHERE projects.client_id = clients.client_id ORDER BY enddate DESC");
echo "<table width=\"500\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n";
while ($row = mysql_fetch_array($strSQL)) {
$strSQL = mysql_query("SELECT filename FROM photos WHERE project_id = '$row[project_id]'");
$row2 = mysql_fetch_array($strSQL);
echo "<tr><td valign=\"top\" width=\"220\"><img src=\"images/$row[project_id]/$row2[filename]\" width=\"200\" alt=\"$row2[filename]\"></td>\n";
echo "<td valign=\"top\"><p><b>$row[project_name]</b></p>\n";
echo "<p>Client: $row[company_name]<br>\n";
echo "Started: $row[startdate]<br>\n";
echo "Finished: $row[enddate]</p>\n";
echo "</td></tr>\n";
}
echo "</table>\n";
There is only one row in the db, which is returning fine. But I'm also getting an extra row with empty fields. Any idea why? Is it because of my combined statement? Is there a better way to do that?