lundi 7 mars 2016

take another table value for dropdown

I have 2 tables student and employer. I have a form that shows Column Student id, Student Name, Employer id(Dropdown for selection).

I Have the following query for db

$sql="SELECT * FROM  student WHERE emp_id IS NULL";
$search_result=mysql_query($sql,$connect);
$sql2="SELECT * FROM  employer ";
$search_result2=mysql_query($sql2,$connect);

And While Loop:

while(($row = mysql_fetch_array($search_result)) && ($row = mysql_fetch_array($search_result2))){
echo"<form action=editstudent.php method=post>";
echo"<tr>";
echo "<td>" . $row['stud_ID']."</td>";
echo "<td>" . $row['stud_NAME']."</td>";
echo "<td>"."<Select name='ex1'>"."<option value='" .$row['emp_id'] ."'>" .$row['emp_id'] ."</option>"."</select>";
echo "<td>" . "<input type='char' name='stud_location' value='" .$row['stud_location'] . "'/> </td>";
echo "<td>" . "<input type='char' name='stud_FIELDOFSTUDY' value='" .$row['stud_FIELDOFSTUDY'] . "'/> </td>";
echo "<td>" . "<input type='char' name='student_yearCompleted' value='" .$row['student_yearCompleted'] . "'/> </td>";
echo "<input type='hidden' name=hidden value=" . $row['stud_ID'] . ">";
echo "<td>" . "<input type='submit' name='submit' value=update". "></td>";
echo "</tr>";
echo "</form>";
}

Ive been getting errors i think from the while loop. It is not accepting the query. I want to make the dropdown from column employer and set it in student table. Any help




Aucun commentaire:

Enregistrer un commentaire