• Howdy! Welcome to our community of more than 130.000 members devoted to web hosting. This is a great place to get special offers from web hosts and post your own requests or ads. To start posting sign up here. Cheers! /Peo, FreeWebSpace.net
managed wordpress hosting

[PHP] Please help

ducktape

NLC
NLC
I have a site where I am trying list properties from a database. I have these set in the database with active = 0 or 1. (0- not active, 1-active) I am trying to present these in a list which i already have done. But if there are no active properties then i want it to post "There are no active listings." If there are active properties then it will show the table with the properties.
 
Code:
if(mysql_fetch_array("SELECT COUNT(*) FROM db WHERE active = 1;")) {
//print the list
} else {
//there are no actives
}

Or assuming you are using a where clause on pulling the actual properties from the database you just need to check whatever local variable (an array I'd assume) that you're storing them in. If the array is empty or full of nulls then you don't display the list.
 
Code:
if(mysql_fetch_array("SELECT COUNT(*) FROM db WHERE active = 1;")) {
//print the list
} else {
//there are no actives
}
Or assuming you are using a where clause on pulling the actual properties from the database you just need to check whatever local variable (an array I'd assume) that you're storing them in. If the array is empty or full of nulls then you don't display the list.

If I could slap you ...

mysql_num_rows ....
 
I know joe...I know there was a better way..I just...haven't used php in a long time (using VB at work, Java/VB.Net at home)

I was actually waiting for you to correct me :p It was late and I was lazy. Bad me :(
 
Back
Top