Jump to content

Archived

This topic is now archived and is closed to further replies.

fizzzgigg

Something simple I am sure

Recommended Posts

[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?

Share this post


Link to post
Share on other sites
i think you're going to have to be a little more specific in your question. also show some code (like your functions).

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
[code]
if (isset($_GET['state'])) {
         query_cities($_GET['state']);
}
elseif (isset($_GET['city'])) {
         query_businesses($_GET['city']);
}
else {
         query_states();
}[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.