PHP Classes

Need help to select and display data from DB

Recommend this page to a friend!

      Top level forums  >  PHP Specialists  >  General  >  Need help to select and display data...  
Subject:Need help to select and display data...
Summary:Need help to select and display data from DB
Messages:4
Author:vishnu s nair
Date:2014-09-22 17:57:34
Update:2014-11-20 04:28:05
 

  1. Need help to select and display data...   Reply   Report abuse  
Picture of vishnu s nair vishnu s nair - 2014-09-22 20:33:47
Hi all,
I am a php student and i am doing a project in php. I am doing the project of online attendance register. I am stuck with the part of reports. We need to select three different values from an HTML form and pick the selected rows and wants to display those rows in a table. I have done a code but it is not working. Please help me out of this issue. HTML Form: [code]<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>

<body><form action="reportpro.php" method="get" name="services">
<table width="447" border="0" align="center" >
<tr style="text-align: center">
<td width="441"><table width="481" border="1">
<tr>
<td width="216"><div align="center">
SECTION
</div></td>
<td width="102"><div align="center">
MONTH
</div></td>
<td width="141"><div align="center">
YEAR
</div></td>

</tr>
<tr>
<td><select name="section" id="select">
<option>SERVICES-A</option>
<option>SERVICES-B</option>
<option>SERVICES-C</option>

</select></td>
<td><select name="month" id="select">
<option>01</option>
<option>02</option>
<option>03</option>
<option>04</option>
<option>05</option>
<option>06</option>
<option>07</option>
<option>08</option>
<option>09</option>
<option>10</option>
<option>11</option>
<option>12</option>
</select></td>
<td><select name="year" id="select">
<option>2014</option>
<option>2015</option>
<option>2016</option>
<option>2017</option>
<option>2018</option>
<option>2019</option>
<option>2020</option>
</select></td>

</tr>



<tr>
<td colspan="4"> <center><input name="submit" type="submit" id="submit" formaction="reportpro.php" formmethod="get" value="Search"></center></td>
</tr>
</table>
<p>&nbsp;

</p>
<p>&nbsp;&nbsp;&nbsp;
</p>
<p>&nbsp;
</p></td>
</tr>
</table>
</form>
</body>
</html>
[/code]


PHP Code: [code]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>

<form action="" method="get">
<table border="1" align="center" >

<tr>
<td>BOOK NO</td>
<td>Name</td>
<td>Desigination</td>
<td>Section</td>
<td>Day</td>
<td>Month</td>
<td>Year</td>

<td>Attendance</td>
</tr>

<?php
$con=mysql_connect("localhost","root","");
mysql_select_db("niy",$con);

$m=$_REQUEST['month'];
$y=$_REQUEST['year'];
$sec=$_REQUEST['section'];

$sql="select month='$m', year='$y', sectn='$sec' from attendance ";
echo $sql;

$res=mysql_query($sql,$con);
while($row=mysql_fetch_array($res))
{
?>
<tr>
<td><?php echo $row[1];?></td>
<td><?php echo $row[2];?></td>
<td><?php echo $row[3];?></td>
<td><?php echo $row[4];?></td>

<td><?php echo $row[5];?></td>
<td><?php echo $m;?></td>
<td><?php echo $y;?></td>
<td><?php echo $row[8];?></td>


</tr>
<?php
}
?>


</table>
</body>
</html>
[/code]

There are 3 replies in this thread, which are not being displayed.
Browsing this forum thread replies is available only to premium subscribers.


Go to the premium subscriptions page to learn how to become a premium subscriber and have full access to this forum.