This is very puzzling. Hopefully someone here can figure it out.
I have the following query
$sql2 = "SELECT rma.ID, rma.product_ID, status.status, rma.date_opened, rma.date_closed " .
"FROM rma, status_lookup, status " .
"WHERE (rma.ID = status_lookup.rma_ID) " .
"AND (status_lookup.status_ID = status.ID) " .
"ORDER BY rma.ID DESC";
Which I use with following code:
$result2 = mysql_query($sql2);
while($row2 = mysql_fetch_array($result2))
{
$rid = $row2["rma.ID"];
$product = $row2["rma.product_ID"];
$state = $row2["status.status"];
$odate = $row2["rma.date_opened"];
$cdate = $row2["rma.date_closed"];
if (!$cdate)
{
echo ("<tr bgcolor='#FFC4C4'>\n");
echo ("<td width='75' align='center'><b>". $rid . "</b></td>\n");
echo ("<td width='250' align='center'>" . $product . "</td>\n");
echo ("<td width='75' align='center'>" . $state . "</td>\n");
echo ("<td width='100' align='center'>" . $odate . "</td>\n");
echo ("<td width='100' align='center'> </td>\n");
echo ("</tr>\n");
}
else
{
echo ("<tr bgcolor='#AEFFAE'>\n");
echo ("<td width='75' align='center'><b>" . $rid . "</b></td>\n");
echo ("<td width='250' align='center'>" . $product . "</td>\n");
echo ("<td width='75' align='center'>" . $state . "</td>\n");
echo ("<td width='100' align='center'>" . $odate . "</td>\n");
echo ("<td width='100' align='center'>" . $cdate . "</td>\n");
echo ("</tr>\n");
}
}
The result is 17 blank rows. I have run several test and have found that all field values are NULL. If I take the SQL statement and run thequery in phpMyAdmin, I get 17 rows filled with data.![]()
Any ideas on what's going on here?
One other question about this query. Each rma.ID goes through several status. I only want to return the last entry in the status_lookup table for a given rma.id ( or status_lookup.rma_ID). Currently the query is returning all entries in the status_lookup table.
Thanks for any help.![]()






Bookmarks