fizzzgigg Posted June 11, 2006 Share Posted June 11, 2006 [code]<? include("functions.php"); query_states();?>[/code]How do I make it so when you click on the a link in the query_states function it will then look for cities in that state, with out having to make a new file to return the results. I dont know how to do it, but I assume it would be something like:[code]<? include("functions.php"); if ($states="null" than do query_states(); Which will show all the states to chose from. if ($states="" than do query_cities(); Which will now display the cities to the selected state. if ($cities="" than do query_businesses(); Which now will display the businesses to the selected city. ?>[/code]Clearly I know that script will not work but what will make it work or should I go about it differently? Quote Link to comment https://forums.phpfreaks.com/topic/11686-something-simple-i-am-sure/ Share on other sites More sharing options...
.josh Posted June 11, 2006 Share Posted June 11, 2006 i think you're going to have to be a little more specific in your question. also show some code (like your functions). Quote Link to comment https://forums.phpfreaks.com/topic/11686-something-simple-i-am-sure/#findComment-44197 Share on other sites More sharing options...
joquius Posted June 11, 2006 Share Posted June 11, 2006 Ok this can be done simply.add a link as page.php?state=<?=$state_id?> beside the state the user can choose (goes for city or whatever subsections you have)then just add this:[code]if (isset ($_GET['state']) && mysql_num_rows (mysql_query ("SELECT `state_id` FROM `states` WHERE `state_id` = '".$_GET['state']."'")) != 0) // this check that $_GET['state'] exists in the db table of states{ $sql = "SELECT * FROM `cities` WHERE `state` = '".$_GET['state']."'"; // set the sql query to list the cities with the state tag equal to the state id which was inputted}[/code] Quote Link to comment https://forums.phpfreaks.com/topic/11686-something-simple-i-am-sure/#findComment-44244 Share on other sites More sharing options...
Barand Posted June 11, 2006 Share Posted June 11, 2006 [code]if (isset($_GET['state'])) { query_cities($_GET['state']);}elseif (isset($_GET['city'])) { query_businesses($_GET['city']);}else { query_states();}[/code] Quote Link to comment https://forums.phpfreaks.com/topic/11686-something-simple-i-am-sure/#findComment-44268 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.