<?php
require("db-connect.php");
$slt ="SELECT * FROM assingment2 ORDER BY user_id asc";
$qry =mysql_query($slt);
?>
<html>
<head><title> </title>
<script language="javascript" type="text/javascript">
function setcourse()
{
var index_name=document.frmselect.name.selectedIndex;
document.frmselect.course.selectedIndex=index_name;
}
</script>
</head>
<body>
<form name="frmselect" id="frmselect" action="" method="post">
<table align="center">
<tr>
<td><b>NAME</b></td><td>
<?php
while($ftch =mysql_fetch_array($qry))
{
echo'<select name="name" id='.$ftch['user_id'].' onChange="javascript:return setcourse();">';
echo '<option value="'.$ftch['user_id'].'">'.$ftch['name'].'</option>';
}
?>
</select>
</td>
</tr>
<tr>
</td>
<td><b>COURSES</b></td>
<td>
<?php
$select="SELECT * FROM assingment3 WHERE user_id=".$ftch['user_id'];
$execute=mysql_query($select);
echo'<select name="course" id="course" >';
while($fetch=mysql_fetch_array($execute))
{
echo '<option value="'.$fetch['id'].'">'.$fetch['courses'].'</option>';
}
?>
</select>
</td>
</tr>
</table>
</form>
<body>
<html>
/*
how will the value of second list box come and how $ftch['user_id'] this put in where condition for selcting data from table with where conditioin pls tell me*/
dev.vini 0 Newbie Poster
Andrey Luiz 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.