Jump to content

AJAX code I think for dynamic dropdown


DeanWhitehouse

Recommended Posts

I have this code for a dynamic dropdown list. These are my lists. i need the second one to be decided from the first option, but without refreshing the page. The first one shows main catergory's and the second sub-catergory's. Can anyone help.

<tr><td><span class="style7">Gallery:</td><td>
    <?php
	$query = "SELECT catergory FROM `image_catergory`";
	$result = mysql_query($query) or die("Error:" . mysql_error());
	?>
	  <select name='folder'>
        <?php
if (mysql_num_rows($result) > 0) 
{

	while ($row = mysql_fetch_assoc($result)) {
	echo "<option>".$row['catergory']."</option>";
	}
}
?>
    </select>
	</span></td>
<?php
	if(mysql_num_rows($result) < 1)
	{
	echo "<tr><td><a href='".$_SERVER['HTTP_HOST']."/add_catagories.php'>Add Catergory</a></td></tr>";
	}
?>
<tr><td><span class="style7">Sub-Gallery:</td><td>
    <?php
	$quey = "SELECT sub_cat FROM `sub_cat`";
	$reult = mysql_query($quey) or die("Error:" . mysql_error());
	?>
	  <select name='subfolder'>
        <?php
if (mysql_num_rows($reult) > 0) 
{

	while ($ow = mysql_fetch_assoc($reult)) {
	echo "<option>".$ow['sub_cat']."</option>";
	}
}
?>
    </select>
	</span></td>
  </tr><tr><td><input type="submit" name="upload" value="Upload"></td></tr></td></tr></table></form>
</form>
<?php
	if(mysql_num_rows($result) < 1)
	{
	echo "<tr><td><a href='".$_SERVER['HTTP_HOST']."/add_catagories.php'>Add Catergory</a></td></tr>";
	}
}
?>

Link to comment
https://forums.phpfreaks.com/topic/107019-ajax-code-i-think-for-dynamic-dropdown/
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.