basically this is a search function.(i have to search the data from database)
<form method="post" action="search.php" name="submitted" value ="true" />
<label>TYPE:
<select name="field">
<option value = "sid">StudentID</option>
<option value = "sname">StudentName</option>
</select>
</label>
<label>WORD:
<input type="text" name="searchword" />
</label>
<input type="submit" />
</form>
<?php
if (isset($_POST['submitted'])){
$con = mysql_connect("localhost","root","");
mysql_select_db("uni", $con) or trigger_error('MySQL error: ' . mysql_error());
$field= $_POST['field'];
$searchword = $_POST['searchword'];
$result = mysql_query("SELECT* FROM student WHERE $field = '$searchword'") or trigger_error('MySQL error: ' . mysql_error());
// = mysql_query($query);
//$num_rows = mysql_num_rows($result);
//echo"num_rows results found.";
echo"<table>";
echo "<tr><th>StudentID</th><th>StudentName</th></tr>";
while($row = mysql_fetch_array($result)){
echo "<tr><td>";
echo "$row ['field']";
echo "</td><td>";
echo "$row ['searchword']";
echo "</td></tr>";
}
echo"</table>";
}
mysql_close($con);
?>