dynamic dropdownlist in php

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
maanikmca
Forum Newbie
Posts: 2
Joined: Mon Mar 07, 2011 12:56 am

dynamic dropdownlist in php

Post by maanikmca »

Hi,

am newbie for PHP here i need to populate one dropdown based on another dropdownlist example,

selection of state and city.

Code: Select all

<select onchange="display_data(this.value);">
    <option>Select employ</option>
    <?php
    mysql_connect('localhost','root','');
    mysql_select_db('shoppingcart');
	
    $query="select catid, name from category ";
    $result=mysql_query($query);
    while(list($id, $name)=mysql_fetch_row($result)) {
        echo "<option value=\"".$id."\">".$name."</option>";
    }
    ?>
</select>

how to do that ?
Post Reply