Jump to content

SQL data not properly showing in dropdown list!


cyandi_man

Recommended Posts

I recently posted an error in my SQL site that has now made some progress.  I now know that the problem lies within the query line itself when pulling data from the SQL database.  this message may seem lengthy but it only looks that way because i am explainignin detail to avoid confusion of what i am asking. 

The following code displays a dropdown menu containing  data that the user must choose from:

$dealerName = "$dealerName";  //input by user
  $query = "SELECT * FROM truckhoods";
  $result = mysql_query($query)
      or die ("Couldn't execute query.");

  /* Display results in a dropdown*/

  echo "<b>$dealerName</b>";
  echo "<form action='javascript: gethoodmodel()'>
  <select name='productName'>\n";
  while ($row = mysql_fetch_array($result))
  {
    extract($row);
    echo "<option value='$productName'>$productName\n";
  }
  echo "</select>\n";
  echo "<input type='submit' value='View Model'>
        </form>\n";
?>

the above version works and can be seen at: www.offsettruckhoodsandbumpers.com/TRUETEST3
(all files are not uploaded so please simply click on the "truckhoods" button in the top nav and pick a dealer name from the top dropdown menu on the right side panel.)  YOu will notice that another dropdown list appears and populates  with ALL dealer numbers.  This is because of the query: [b]"SELECT * FROM truckhoods";[/b] in the coding above. 

The main idea here is to select only the items related to the PARTICULAR dealer choosen from the first dropdown menu.  I used the  line of query below - when simply using a post method in which a blank page with the dropdown takes you to another blank page with the last dropdown and then finally the last page with the data. (in other words using the php files on there own with a post method instead of the includes that target a particular window within the site:

[b]"SELECT * FROM truckhoods WHERE dealerName='$dealerName";[/b]

this line works when the php code is used by itself but not when within my site ...why?  is there another line of code needed to transfer info from one dropdown menu to the other so only the specific information is populated in the list?

Please help as i am soooo close to finishing this portion of the site!
anyone's help would be greatly appreciated!
Link to comment
Share on other sites

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.