<select name="year">
<option value="2010">2010</option>
<option value="2011">2011</option>
<option value="2012">2012</option>
<option value="2013">2013</option>
</select>
<input type="submit" name="sub" value="Search"/>
</div>
<?php
if(isset($_REQUEST['sub'])){
$year=$_REQUEST['year'];
$con=mysql_connect("localhost","root","")or die( "Unable to connect");
mysql_select_db("mydb",$con) or die( "Unable to select database");
$query="SELECT * FROM student WHERE EnrolledYear='$year'";
$result=mysql_query($query)or die(mysql_error());;
$num=mysql_numrows($result);
mysql_close();
?>
<table>
<tr>
<th>Student ID No.</font></th>
<th>Name</font></th>
<th>Enrolled Terms</font></th>
<th>Enrolled Years</font></th>
</tr>
<?php
$i=0;
while ($i < $num) {
$f1=mysql_result($result,$i,"StudentID");
$f2=mysql_result($result,$i,"FullName");
$f3=mysql_result($result,$i,"EnrolledTerm");
$f4=mysql_result($result,$i,"EnrolledYear");
?>
<tr>
<td><?php echo $f1; ?></font></td>
<td><?php echo $f2; ?></font></td>
<td><?php echo $f3; ?></font></td>
<td><?php echo $f4; ?></font></td>
</tr>
<?php
$i++;
}
}
?>
maemaumeow 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.