for example i have the insert form
Code:
<form method="post" action="classes.php">
<select name=semester>
<option value=''></option>
<option value='1'>1</option>
<option value='2'>2</option>
<option value='3'>3</option>
<option value='4'>4</option>
</select>
<submit button></form>
classes.php is something like
Code:
<?php
.....
$sql="insert into classes ....semester='$_POST["semester"]'";
$res=mysql_db_query();
?>
when I click on update class I want to run an sql query and retrieve all data from database that are related to that class and preview the class' edit form as follows
Code:
<form action=\"classes.php\" method=\"post\" onsubmit=\"return validate_class();\">
<input type="hidden" name="class_id" value=".$result["id"]." />
<table >
<tr>
<td>
Class name (*) </td>
<td>
<input type="text" name="class_name" value=".stripslashes($result["name"])."></td>
</tr>
<tr>
<td>
Class code (*) </td>
<td>
<input type="text" name="class_name" value=".stripslashes($result["code"])."></td>
</tr>
<tr>
<td>
Semester (*) </td>
<td>
<select name=semester>
<option value=''></option>
<option value='1'>1</option>
<option value='2'>2</option>
<option value='3'>3</option>
<option value='4'>4</option>
</select>
</td>
</tr>
</table><submit button></form>
but I want the right semester to be selected in the edit form when I load it. When inserted the class i selected that the class belongs to the 2nd semester. When I click on update class I want the select element to have the right semester selected and not to be blank and waiting for me to choose semester again.
Bookmarks