Jump to content

2 dependent dropdown box from 1 table


chen2424

Recommended Posts

hi guys,

 

I have 1 table jos_abc and i want to pull 2 fields tt reside in this table into my form in 2 dropdowns. 1 is brand and 1 is flavour. So if brand is dropdown and benjerrys is selected, flavour dropdown will show flavours only for benjerrys. kind of like this http://www.whatcar.com/ but i dont need the ajax. js is fine.

 

this is what i have so far, hw do i write rest of code? any insight pls, :confused:

<?php 
if(isset($_POST['action'])) 
  { 
  // handle submitted form data 
  // then redirect 
  } 

?> 
<html> 

<head> 
<title></title> 
</head> 

<body> 
<form method="post" action="<?=( $_SERVER['PHP_SELF'] )?>"> 
<select name="title" onchange="this.form.submit();"> 
  <option value=""> -- Select --</option> 

<?php
mysql_connect("localhost", "username", "password") or die(mysql_error());
mysql_select_db("mydb") or die(mysql_error());

    $sql = 'SELECT id , brand FROM jos_icecream ORDER BY brand'; 
        $result = mysql_query($sql); 
?> 


</select><noscript> <input type="submit" value=" Refresh " /></noscript> 
<input type="submit" name="action" value=" Submit " /> 
</form> 
</body> 

</html>

Link to comment
https://forums.phpfreaks.com/topic/180447-2-dependent-dropdown-box-from-1-table/
Share on other sites

Archived

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

×
×
  • 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.