I want to call php function in dropdown menu by onchange event. I want with choose one of the options, the appropriate valuse are read from database and are list in another dropdown menu.
code:
<?php
function read() {
mysql_connect("localhost", "username", "password");
mysql_select_db("database_name");
$sql = mysql_query("SELECT name FROM table");
if (mysql_num_rows($sql)) {
$select = '<select name="select">';
while ($rs = mysql_fetch_array($sql)) {
$select.='<option value="' . '">' . $rs['name'] . '</option>';
}
}
$select.='</select>';
echo $select;
}
?>
<!--html code -->
<select onchange="document.write('<?php read(); ?>');">
<option value="0">a</option>
<option value="1">b</option>
<option value="2">c</option>
</select>
How can I get My desired output ? Thanks

