Jump to content


Photo

Something simple I am sure


  • Please log in to reply
3 replies to this topic

#1 fizzzgigg

fizzzgigg
  • Members
  • PipPipPip
  • Advanced Member
  • 35 posts

Posted 11 June 2006 - 03:59 AM

<?
      include("functions.php");
      
    query_states();
?>

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:
<?
      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. 
?>

Clearly I know that script will not work but what will make it work or should I go about it differently?



#2 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 11 June 2006 - 06:09 AM

i think you're going to have to be a little more specific in your question. also show some code (like your functions).
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#3 joquius

joquius
  • Members
  • PipPipPip
  • Advanced Member
  • 319 posts

Posted 11 June 2006 - 12:25 PM

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:
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
}

z..z..z..z..z..z..z..z..

#4 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,017 posts

Posted 11 June 2006 - 01:51 PM

if (isset($_GET['state'])) {
         query_cities($_GET['state']);
}
elseif (isset($_GET['city'])) {
         query_businesses($_GET['city']);
}
else {
         query_states();
}

If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users