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