Page 1 of 1

If ListingID is in property session table, then display one

Posted: Sat Jan 30, 2010 1:08 pm
by REwing
Hello, i hope you can help.

I have two tables, listings and property_session

I'm trying to write some code which basically says:

If ListingID is in property session table, then display one image if not then display another.

Can anyone help?

Re: If ListingID is in property session table, then display one

Posted: Sat Jan 30, 2010 2:01 pm
by AbraCadaver
Assuming MySQL and that you have the ID in $ListingID:

Code: Select all

$result = mysql_query("SELECT * from property_session WHERE ListingID = '$ListingID'");
 
if (mysql_num_rows($result) > 0) {
    //found 
    //echo an image
} else {
    //not found
    //echo another image
}