Jump to content

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

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.