Hi,
I am trying to query and get resulst for two seperate tables.
$query="SELECT * FROM residential WHERE Id like '$Id'";
$query2="SELECT * FROM featuredlistings WHERE Id like '$Id'";
$result=mysql_query($query) or die (mysql_error());
$result2=mysql_query($query2) or die (mysql_error());
//$result2=mysql_query($query2) or die (mysql_error());
$num=mysql_numrows($result);
?>
<?
if(mysql_numrows($result) == '0') {
echo "Sorry, no results were found...";
} else {
// display results here
}
?>
<?
while ($row = mysql_fetch_array($result)) // this will grab the results from query
while ($row2 = mysql_fetch_array($result2)) // this will grab the results from query2
{
?>
Notince these lines:
$query="SELECT FROM residential WHERE Id like '$Id'";
$query2="SELECT FROM featuredlistings WHERE Id like '$Id'";
The problem I am having is if featuredlistings DOES NOT have and Id like '$Id'
If this is true than it stops displaying the results from the first query.
So, I want to get results from both queries...and if no results are found for query2, it should just ignore query2....
Does this make since? Maybe I am not doing this correctly....basically I am attempting to cross reference two tables and get the results from both tables.