PHP Example
Screen shot
index.php

<?php
$con=mysql_connect('localhost','root','') or die("Mysql not connected");
mysql_select_db('student',$con) or die("Database not connected");
?>
<html>
<head>
<title>Student Result</title>
</head>
<body>
<table width="300" border="1" cellspacing="0" cellpadding="0" align="center"
bgcolor="#FFCC99">
<tr bgcolor='red'>
<td colspan="2" align="center"> <h2>RESULT</h2></td>
</tr>
<tr>
<td colspan="2" align="center">
<form name="frm" action="" method="post">
<h4>Enter Roll Number</h4><input name="roll_no" type="text" />
<input name="btn" type="submit" value="Search" />
</form>
</td>
</tr>
<?php
if(isset($_POST['btn']))
{
$roll_no=$_POST['roll_no'];
$query="select * from result where Roll_No=$roll_no";
$result=mysql_query($query);
$rows=mysql_num_rows($result);
if($rows==0)
{
?>
<tr>
<td colspan="2" align="center"><?php echo "Roll number not found"; ?></td>
</tr>
<?php
}
else
{
while($data=mysql_fetch_array($result))
{
?>
<tr>
<td align="left" colspan="2"> <b>Roll No.: <?php echo $data[1] ?> </b></td>
</tr>

<tr>
<td align="left" colspan="2"> <b>Name : <?php echo $data[2] ?> </b></td>
</tr>
<tr>
<td align="left" colspan="2"><b>Father's Name : <?php echo $data[3] ?></b></td>
</tr>
<tr>
<td align="center">Hindi</td>
<td align="center" width="50%"><?php echo $data[4] ?></td>
</tr>
<tr>
<td align="center">Math</td>
<td align="center"><?php echo $data[5] ?></td>
</tr>
<tr>
<td align="center">English</td>
<td align="center"><?php echo $data[6] ?></td>
</tr>
<tr>
<td align="center">Physics</td>
<td align="center"><?php echo $data[7] ?></td>
</tr>
<tr>
<td align="center">Chemistry</td>
<td align="center"><?php echo $data[8] ?></td>
</tr>
<td align="center"><b>Total :
<?php
$total=$data[4]+$data[5]+$data[6]+$data[7]+$data[8];
?>
<td align="center">
<?php
echo "<b>$total</b>";
?>
</td></b></td>
</tr>
<tr>
<td align="center" colspan="2"><b>Division :
<?php
$per=$total/5;
if($per>=60)
echo "1st Division";
elseif($per>=45 && $per<60)
echo "2nd Division";
elseif($per>=33)
echo "3rd Division";
else
echo "fail";
?>
</b></td>
</tr>
<?php
}
}
}
?>
</table>
</body>
</html>

Mysql Database

--
-- Database: `student`
--

-- --------------------------------------------------------

--
-- Table structure for table `result`
--

CREATE TABLE IF NOT EXISTS `result` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `Roll_No` int(11) NOT NULL,
  `Name` varchar(100) NOT NULL,
  `Fahter_Name` varchar(100) NOT NULL,
  `Hindi` int(11) NOT NULL,
  `Math` int(11) NOT NULL,
  `English` int(11) NOT NULL,
  `physics` int(11) NOT NULL,
  `chemistry` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;

--
-- Dumping data for table `result`
--

INSERT INTO `result` (`id`, `Roll_No`, `Name`, `Fahter_Name`, `Hindi`, `Math`, `English`, `physics`, `chemistry`) VALUES
(1, 1001, 'suresh', 'ramesh', 50, 40, 70, 78, 98),
(2, 1002, 'ashu', 'manoj', 50, 80, 70, 13, 65);

You can download source code here