I made a page that contain two drop dowwn menus
the first for the name of the groups
The second for the name of the friends
when i choose from the first menu, the name of the friends that is related to that group must appear on the second one.
I wrote the following code:
Code: Select all
<?php
$conn=mysql_connect("localhost","root","");
mysql_select_db("exp",$conn);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script type="text/javascript" language="javascript">
function MM_jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}
</script>
<title>Untitled Document</title>
</head>
<body>
<form name="dpmenu" action="drop.php" method="post">
Select a Group:
<select name="groups" id="groups" onchange="MM_jumpMenu('parent',this,0)">
<?php
$sql="SELECT gpid,gpname FROM groups ";
$result = mysql_query("$sql",$conn);
while ($groups= mysql_fetch_array($result)) {
$gpid = $groups['gpid'];
$gpname = $groups['gpname'];
echo "<option value='drop.php?id=$gpid'>$gpname </option>\n";
}
?>
</select>
<p>
Select a Friend:
<select name="friends" id="friends" >
<?php
$query="Select frid,fname,friends.gpid,groups.gpid from friends,groups where groups.gpid = friends.gpid ";
$res= mysql_query("$query",$conn);
while($friends= mysql_fetch_array($res))
{
//$fid = $friends['frid'];
$fname = $friends['fname'];
echo "
<option value='$gpid' >$fname</option> \n";
}
?>
</select>
</p>
</form>
</body>
</html>
Can any one help me please?