1

I've looked all over but can't find anything similar to my question.

I have a table like this:

Fleet Name | Vehicle Reg
    xxx    |     w
    xxx    |     x
    yyy    |     y
    yyy    |     z

I've made a dropdown/select which shows xxx & yyy:

SELECT DISTINCT fleet_name FROM eco_drive_table

Now I want to make another dropdown/select which will only show w & x when xxx selected and only show y & z when yyy is selected and then output the vehicle reg as a string

Hope that makes sense,

I'm using PHP.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
SiZa
  • 127
  • 1
  • 11
  • 3
    http://stackoverflow.com/questions/10570904/use-jquery-to-change-a-second-select-list-based-on-the-first-select-list-option – user2615302 Oct 31 '13 at 13:43

1 Answers1

1

Store the value from the xxx and yyy into a variable. Than query using the WHERE condition;

SELECT * FROM eco_drive_table WHERE fleet_name='$variavle';

So when the user select xxx $variable is xxx, when select yyy $variable is yyy

  • ok makes sesne but how do I store the xxx and yyy's value into a variable? this is what the code is now: – SiZa Oct 31 '13 at 14:29
  • {$row['vehicle_reg']}"; } ?> – user2883341 Oct 31 '13 at 18:13
  • Select Fleet Name: "; $sql = "SELECT vehicle_registration_number FROM eco_drive_table WHERE fleet_name='$fleet_name'"; $query = mysql_query($sql); echo "

    Select Vehicle Registration:

    "; ?>
    – SiZa Nov 01 '13 at 15:22
  • thats the code i've got now but the second select option is pulling out two random vehicle regs and doesn't respond to the first select box, thanks for your help so far! – SiZa Nov 01 '13 at 15:23