View Full Version : [PHP] Please help
ducktape
June 24th, 2008, 21:39
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.
ducktape
June 24th, 2008, 23:12
Ok stupid me I got it. Sorry!!! :classic2:
Corazu
June 24th, 2008, 23:21
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.
krakjoe
June 25th, 2008, 05:11
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 ....
Corazu
June 25th, 2008, 18:46
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 :(
Powered by vBulletin® Version 4.1.7 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.