Jump to content

Why doesnt my 2nd drop down have distinct values?


wright67uk

Recommended Posts

Ive been scanning over and over this code and I cant work out why my 2nd drop down menu doesnt have unique values.

Please if anyone can give me guidance, you never know I may be able to get rid of my headache!

 

<body>
<p>
<form action="" method="post">
<select name="drop_1" id="drop_1"> 
<option value="" selected="selected" disabled="disabled">Select a Category</option>  
<?php getTierOne(); ?>
</select> 
<span id="wait_1" style="display: none;">
<img alt="Please Wait" src="ajax-loader.gif"/>
</span>
<span id="result_1" style="display: none;"></span>   
</form>
</p>
<p>
<?php if(isset($_POST['submit'])){
$drop = $_POST['drop_1'];
$tier_two = $_POST['Subtype'];
echo "You selected ";
echo $drop." & ".$tier_two;
}
?>
</body>

 

<?php
function getTierOne()
{
$result = mysql_query("SELECT DISTINCT Type FROM business") 
or die(mysql_error());
while($tier = mysql_fetch_array( $result ))   
{
echo '<option value="'.$tier['Type'].'">'.$tier['Type'].'</option>';
}
}
if($_GET['func'] == "drop_1" && isset($_GET['func'])) { 
   drop_1($_GET['drop_var']); 
}
function drop_1($drop_var)
{  
include_once('db.php');
$result = mysql_query("SELECT DISTINCT Subtype FROM business WHERE Type='$drop_var'") 
or die(mysql_error());	
echo '<select name="Subtype" id="Subtype">
<option value=" " disabled="disabled" selected="selected">Choose one</option>';
while($drop_2 = mysql_fetch_array( $result )) 
{
echo '<option value="'.$drop_2['Subtype'].'">'.$drop_2['Subtype'].'</option>';
}	
echo '</select> ';
echo '<input type="submit" name="submit" value="Submit" />';
}
?>

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.