PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
tags where approriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
Below is a snippet of code that has me confused.
$filterCode = "WHERE city = '$city' and state = '$st'";
$getZONE = "SELECT zone FROM zones $filtercode";
$getCount = mysql_query( $getZONE );
$countnum = mysql_num_rows( $getCount );
if ($countnum == 0) {
$zone = 99;
} else {
$zone = mysql_query( $getZONE );
}
The code always returns 99 for $zone. When I view $filtercode later on in the script, there's nothing there. When I view $getZONE, all I get is "SELECT zone FROM zones".
Could someone shed some light on this and get me out of the dark? I can't see the forest right now because there are too many trees in the way. patrikG | Help us, help you. Please use
You should also note that if your query returns any rows then your code snippet executes the query again (and $zone becomes a resource identifier (is this the desired behaviour)), there is no point in this as you already have the result set.
tags where approriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
Thanks. I just could not see the "C" instead of the "c". Would this code work better (based on your suggestion)?