I have an application I'm writing that will take a list of people that have set up searches for a local MLS database, query the MLS database and email them new listings that match their criteria. I'm having a heck of a time with a nested query. I have included what I have so far...
//Start by getting the list of registered searches
$query = "SELECT * FROM searches";
$result = mysql_query($query)
or die ("Unable to get query data from database");
$nrows = mysql_num_rows($result);
for ($i=0;$i<$nrows;$i++)
{
$row = mysql_fetch_array($result);
extract($row); //Gives the search criteria for each row
//echo "<br>User $user_id - Search ID $search_id - Table $table - Price Range = $lprice-$uprice - $BEDROOMS Bed - $BATHS_TOT Bath - $ACRES Acres - Zip = $ZIP - City = $CITY - $SQFT sqft<br>";
//Query the MLS database with the paramaters from the search in the search table
$query2 = "select * from $table WHERE (CITY LIKE '$CITY' AND ZIP LIKE '$ZIP')";
//AND PRICE BETWEEN '$lprice' AND '$uprice'
//AND BATHS_TOT >='$BATHS_TOT' AND BEDROOMS >='$BEDROOMS'";
$result2 = mysql_query($query2)
or die ("Unable to query MLS database with query information from search table");
$nrows2 = mysql_num_rows($result2);
for ($j=0;$j<$nrows2;$j++)
{
echo "Table = $table - $LISTING_ID"; }
} //End for loop - getting list of registered searches
When I echo the variables from the first query they are all there and properly formatted. When the second query goes off, it dies at the die statement.
Is there something obvious that I'm not seeing?!?
Thanks in advance for any help you can offer.
Matt