Here is a script for beginners to create a dynamic loading of dropdown. Simple solution which is created by jQuery.
Table Structure
1 2 3 4 5 6 |
CREATE TABLE IF NOT EXISTS `ajax_categories` ( `id` int(11) NOT NULL AUTO_INCREMENT, `category` varchar(50) NOT NULL, `pid` int(11) NOT NULL, PRIMARY KEY (`id`) ) |
get_child_categoires.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
<!--?php if($_REQUEST) { $id = $_REQUEST['parent_id']; $query = "select * from ajax_categories where pid = ".$id; $results = mysql_query( $query);?--><select id="sub_category_id" name="sub_category"> <option selected="selected" value=""></option> <!--?php while ($rows = mysql_fetch_assoc(@$results)) {?--> <option value="<?php echo $rows['category'];?> ID=<?php echo $rows['id'];?>"><!--?php echo $rows['category'];?--></option> <!--?php }?--> </select> <!--?php }?--> |
HTML
Select Category
Select Sub Category

1 |
thank you great code.
How i can implant like this on wordpress?
this code sucks, no category in database
at least he shared what he got.. and the code i think is good enough to know the basic.