Before the change:
Code: Select all
<?php include_once("includes/header.php");?>
<form name="student_frm" action="">
<table width="90%" border="2" align="center">
<tr>
<th colspan="4" scope="col">Student Registration Form</th>
</tr>
<tr>
<th>First Name</th>
<td><input name="st_frtname" type="text" id="st_frtname"></td>
<th>Last Name</th>
<td><input name="st_ltname" type="text" id="st_ltname"></td>
</tr>
<tr>
<th>Address Line 1</th>
<td><textarea name="st_address1" id="st_address1"></textarea></td>
<th>Address Line 2</th>
<td><textarea name="st_address2" id="st_address2"></textarea></td>
</tr>
<tr>
<th>City</th>
<td>
<select name="st_city" id="st_city">
<?php ###echo get_option_list("city","city_id","city_name"); ?>
</select>
</td>
<th>State</th>
<td><select name="st_state" id="st_state">
<?php ###echo get_option_list("state","state_id","state_name"); ?>
</select>
</td>
</tr>
<tr>
<th>Country</th>
<td><select name="st_country" id="st_country">
<?php ###echo get_option_list("country","country_id","country_name"); ?>
</select>
</td>
<th>Citizenship</th>
<td><input name="st_citizen" type="text" id="st_citizen"></td>
</tr>
<tr>
<th>Gender</th>
<td>
<input name="st_gender" type="radio" value="radiobutton">Male
<input name="st_gender" type="radio" value="radiobutton">Female
</td>
<th>Qualification</th>
<td>
<div style="height:100; overflow:scroll">
<?php ###echo get_check_list("course","course_id","course_name","st_qualify"); ?>
</div>
</td>
</tr>
<tr>
<th>Course</th>
<td><select name="st_course" id="st_course"></select></td>
<th>picture</th>
<td><input name="st_picture" type="file" id="st_picture"></td>
</tr>
<tr>
<th>Hobbies</th>
<td><textarea name="st_hobbies" id="st_hobbies"></textarea></td>
<th>Mobile</th>
<td><input name="st_mobile" type="text" id="st_mobile"></td>
</tr>
<tr>
<th colspan="4">
<input type="submit" name="submit" value="Submit">
<input type="reset" name="submit2" value="Reset">
</th>
</tr>
</table>
</form>
<?php include_once("includes/footer.php");?>After the change:
Code: Select all
<?php include_once("includes/header.php");?>
<form name="student_frm" action="">
<table width="90%" border="2" align="center">
<tr>
<th colspan="4" scope="col">Student Registration Form</th>
</tr>
<tr>
<th>First Name</th>
<td><input name="st_frtname" type="text" id="st_frtname"></td>
<th>Last Name</th>
<td><input name="st_ltname" type="text" id="st_ltname"></td>
</tr>
<tr>
<th>Address Line 1</th>
<td><textarea name="st_address1" id="st_address1"></textarea></td>
<th>Address Line 2</th>
<td><textarea name="st_address2" id="st_address2"></textarea></td>
</tr>
<tr>
<th>City</th>
<td>
<select name="st_city" id="st_city">
<?php echo get_option_list("city","city_id","city_name"); ?>
</select>
</td>
<th>State</th>
<td><select name="st_state" id="st_state">
<?php ###echo get_option_list("state","state_id","state_name"); ?>
</select>
</td>
</tr>
<tr>
<th>Country</th>
<td><select name="st_country" id="st_country">
<?php ###echo get_option_list("country","country_id","country_name"); ?>
</select>
</td>
<th>Citizenship</th>
<td><input name="st_citizen" type="text" id="st_citizen"></td>
</tr>
<tr>
<th>Gender</th>
<td>
<input name="st_gender" type="radio" value="radiobutton">Male
<input name="st_gender" type="radio" value="radiobutton">Female
</td>
<th>Qualification</th>
<td>
<div style="height:100; overflow:scroll">
<?php ###echo get_check_list("course","course_id","course_name","st_qualify"); ?>
</div>
</td>
</tr>
<tr>
<th>Course</th>
<td><select name="st_course" id="st_course"></select></td>
<th>picture</th>
<td><input name="st_picture" type="file" id="st_picture"></td>
</tr>
<tr>
<th>Hobbies</th>
<td><textarea name="st_hobbies" id="st_hobbies"></textarea></td>
<th>Mobile</th>
<td><input name="st_mobile" type="text" id="st_mobile"></td>
</tr>
<tr>
<th colspan="4">
<input type="submit" name="submit" value="Submit">
<input type="reset" name="submit2" value="Reset">
</th>
</tr>
</table>
</form>
<?php include_once("includes/footer.php");?>Here is the function.php file
Code: Select all
<?php
###Function to generate dynamic option list###
function get_option_list($table,$col_id,$col_value,$sel=0)
{
$SQL="SELECT * FROM $table ORDER BY $col_value";
$rs=mysql_query($SQL) or die(mysql_error());
$option_list="<option value=0>Please Select</option>";
while($data=myssql_fetch_assoc($rs))
{
$option_list.="<option value='$data[$col_id]'>
$data[$col_value]</option>";
}
return $option_list;
}
###Function to generate dynamic checkbox###
function get_check_list($table,$col_id,$col_value,$name,$sel=0)
{
$SQL="SELECT * FROM $table ORDER BY $col_value";
$rs=mysql_query($SQL) or die(mysql_error());
$option_list="";
while($data=myssql_fetch_assoc($rs))
{
$option_list.="<input type='checkbox' name='$name' value='$data[$col_id]'>$data[$col_value]<br>";
}
return $option_list;
}
?>