I have the following PHP code that I'm trying to use to find a real estate listing that could be in one of 5 db tables.
$db_table = array ("residential","farm","multifamily","commercial","land");
for ($i=0;$i<=sizeof($db_table);$i++)
{
$query = "SELECT * FROM $db_table[$i] WHERE LISTING_ID='$LISTING_ID'";
$result = mysql_query($query)
or die ("Unable to execute query");
$row = mysql_fetch_array($result);
if (sizeof($row)>0)
{
header("Location: ../Listing_Detail.php?table=$db_table[$i]&listing=$LISTING_ID");
}
}
The LISTING_ID variable passes fine, but every time I run the script the page redirects with the final entry in the $db_table array. I'm almost certain that the problem lies where I am trying to see if the search gave any results ... if(sizeof($row)>0)...
Can someone tell me if I'm headed in the right direction?
Thanks in advance.