Hi All,
This PHP program will help you to do combobox, dynamic combobox from table, form validation , auto id generation in php form, delete from form, upload image in php etc.
---------------------------------------------------------------------------------------
<html>
<body>
<form action=savestudent.php method=post>
<table>
<tr>
<td>Id</td>
<td><input name=id ></td>
</tr>
<tr>
<td>Name</td>
<td><input name=name ></td>
</tr>
<tr>
<td>Course</td>
<td>
<select name=name >
<option value=c1>MCA</option>
<option value=c2>MTech</option>
<option value=c3>BTech</option>
</select>
</td>
</tr>
<tr>
<td>Gender</td>
<td>Male <input type=radio name=gender value=male >Female <input type=radio name=gender value=female ></td>
</tr>
<tr>
<tr>
<td></td>
<td><input type=submit value='Save'></td>
</tr>
</table>
</form>
</body>
</html>
-----------------------------------------------------------------------------------------------------------------
Now Combobox values can be generated by using table and function
So create a table course with courseid and coursename
<htm>
<body>
<?php
$con=mysql_connect("localhost","root","");
mysql_select_db("hup");
function showcombobox()
{
$sql="select courseid,coursename from course";
echo $sql;
$data=mysql_query($sql);
$retvalue='';
while($row=mysql_fetch_array($data))
{
$retvalue=$retvalue."<option value='".$row['courseid']."'>".$row['coursename']."</option>";
}
echo $retvalue;
}
?>
<form action=savestudent.php method=post>
<table>
<tr>
<td>Id</td>
<td><input name=id ></td>
</tr>
<tr>
<td>Name</td>
<td><input name=name ></td>
</tr>
<tr>
<td>Course</td>
<td>
<select name=name >
<?php
showcombobox();
?>
</select>
</td>
</tr>
<tr>
<td>Gender</td>
<td>Male <input type=radio name=gender value=male >Female <input type=radio name=gender value=female ></td>
</tr>
<tr>
<tr>
<td></td>
<td><input type=submit value='Save'></td>
</tr>
</table>
</form>
</body>
</html>
This PHP program will help you to do combobox, dynamic combobox from table, form validation , auto id generation in php form, delete from form, upload image in php etc.
---------------------------------------------------------------------------------------
<html>
<body>
<form action=savestudent.php method=post>
<table>
<tr>
<td>Id</td>
<td><input name=id ></td>
</tr>
<tr>
<td>Name</td>
<td><input name=name ></td>
</tr>
<tr>
<td>Course</td>
<td>
<select name=name >
<option value=c1>MCA</option>
<option value=c2>MTech</option>
<option value=c3>BTech</option>
</select>
</td>
</tr>
<tr>
<td>Gender</td>
<td>Male <input type=radio name=gender value=male >Female <input type=radio name=gender value=female ></td>
</tr>
<tr>
<tr>
<td></td>
<td><input type=submit value='Save'></td>
</tr>
</table>
</form>
</body>
</html>
-----------------------------------------------------------------------------------------------------------------
Now Combobox values can be generated by using table and function
So create a table course with courseid and coursename
<htm>
<body>
<?php
$con=mysql_connect("localhost","root","");
mysql_select_db("hup");
function showcombobox()
{
$sql="select courseid,coursename from course";
echo $sql;
$data=mysql_query($sql);
$retvalue='';
while($row=mysql_fetch_array($data))
{
$retvalue=$retvalue."<option value='".$row['courseid']."'>".$row['coursename']."</option>";
}
echo $retvalue;
}
?>
<form action=savestudent.php method=post>
<table>
<tr>
<td>Id</td>
<td><input name=id ></td>
</tr>
<tr>
<td>Name</td>
<td><input name=name ></td>
</tr>
<tr>
<td>Course</td>
<td>
<select name=name >
<?php
showcombobox();
?>
</select>
</td>
</tr>
<tr>
<td>Gender</td>
<td>Male <input type=radio name=gender value=male >Female <input type=radio name=gender value=female ></td>
</tr>
<tr>
<tr>
<td></td>
<td><input type=submit value='Save'></td>
</tr>
</table>
</form>
</body>
</html>
No comments:
Post a Comment