Jump to content

Recommended Posts

Okay so I have one page has a drop down menu once the user selects the first option it will then display a 2nd drop down once they select there next option I pass that value and now I am having a hard time making it keep that value and only displaying the data that would match that value in the database.

 

I have no issue passing one value to another dropdown box thats easy plus I am using ajax could some one help me write an array to HOLD the selected value and then only find the information attached to that value.

 

Here is the code I was trying. The code starts at the getpart command

 

// =====================================================================================================
// Construct parts overview after user selected state, city.
// =====================================================================================================
if( (isset($_GET['getpart']) AND isset($_GET['state']) AND isset($_GET['city']))
    OR (isset($_GET['search']) ) ) {
  if(isset($_GET['getpart'])) {  
     $st = $_GET['state']; 
     $ci = $_GET['city']; 
     $query="SELECT dealerlocater.state, ".
            " dealerlocater.company, dealerlocater.address, dealerlocater.city, dealerlocater.stateabb, dealerlocater.zip, dealerlocater.phone, dealerlocater.web ".
            " FROM dealerlocater ".
            " WHERE state='$st' ".
            " GROUP BY dealerlocater.state ".
            " ORDER BY dealerlocater.state ";
  }
$res = mysql_query($query)
  or die("Invalid query: " . mysql_query());
// verify that the part number has been passed
if (!isset($_REQUEST['city']) OR strlen(trim(strip_tags($_REQUEST['city']))) < 4 )
   die("Invalid city specified.");
// sanitize and save the requested part number
$city = trim(strip_tags($_REQUEST['city']));
// select the data row for the specified part number
$res = mysql_query("SELECT * FROM dealerlocater WHERE city='$city' LIMIT 1")
   or die("Invalid select query: " . mysql_query());
// verify that a row has been selected, if not: issue message
if (mysql_num_rows($res) < 1)
   echo "No database information for '$city' found.";
// a row had been selected, process the data
else {
  $row = mysql_fetch_assoc($res);
  $city = $row['city'];
  $st = $row['state'];
  
echo $city;

?>

 

If you need the full page 1 code and full page 2 code please let me know.

Link to comment
https://forums.phpfreaks.com/topic/86355-some-help-with-arrays-displaying-results/
Share on other sites

hmm sorry let me fix it.

 

I have one page that has a drop down menu, once the user selects the desired option it will then pass the selected value to a 2nd drop down. Once they select there next option I pass that value...

Now I would like to hold the 2nd selected value have it search the database find all that match the selected and then only display what matches it in the corresponding ROWS in the database.

 

Does that help clear things up?  :-\

 

have you tried storing the data in a $_SESSION ?

$_SESSION['secondValue'] = whatEver;

 

I have never used that before  ???

 

I was hoping to get some help with an array because I would like it, to display the infromation found in a format of an address for example

 

Company Name

Address

City, State Zip Code

Phone Number

Website

 

 

The user is selecting there "STATE" Once selected it pass that value to "getCity" Then displays a list of "City's" in the selected "STATE"

 

So once they select "CITY" id like it to display all Companys found in that "CITY" in the format I listed above

 

Does this help more?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.