PHP Lab Program For MCA
PHP Lab Program For MCA
highlighted.
Conn.php
<?php
mysql_connect('localhost', 'root','password')or
die("Could not connect: " . mysql_error());
mysql_select_db("table1");
?>
Attend.php
<?php
include('conn.php');
echo "<form method=post name=f1 action=' ' onsubmit='return validate()'><h1> Enter
Attendance</h1>";
echo "<p><Table class=table border=1 ><tr><td>
<tr><td> Semester
<td>";
</select>
<tr><td>
Month<td>
<tr><td>
<tr><td>
Subject<td>
</select>
<tr><td>
Total Classes<td>
<input type="text" placeholder="Total Attendance" name="tot" id="tot" value="<?php echo
$_GET[totalclass];?>" >
<tr><td>
Obtained Classes<td>
<input type="text" placeholder="Total Attendance" name="obt" id="obt" value="<?php echo
$_GET[totalclass];?>" >
<?php
echo "<tr><td><td><input type=submit name=submit value=Submit class=templatemo-blue-button
width-100></td>";
echo "</tr></table></form>";
?>
<br><br>
<br><br>
<?php
$tot=$_POST["tot"];
$sub=$_POST["sub"];
$sem=$_POST["sem"];
$mon=$_POST["mon"];
$rno=$_POST["rno"];
$obt=$_POST["obt"];
if(isset($_POST['submit']))
{
$result=mysql_query($sql) or die(mysql_error());
}
?>
</body>
</html>
viewatt.php
<?php
include('conn.php');
echo "<form method=post name=f1 action=' ' onsubmit='return validate()'><h1>View Attendance
</h1>";
echo "<p><Table class=table border=1 ><tr><td>
<tr><td> Semester
<td>";
<tr><td>
<tr><td>
Subject<td>
</select>
<?php
echo "<tr><td><td><input type=submit name=submit value=Submit class=templatemo-blue-button
width-100></td>";
echo "</tr></table></form>";
?>
<br><br>
<?php
$tot=$_POST["tot"];
$sub=$_POST["sub"];
$sem=$_POST["sem"];
$mon=$_POST["mon"];
$rno=$_POST["rno"];
echo $tot;
echo $sub;
if(isset($_POST['submit']))
{ $result = mysql_query("SELECT * FROM attendance where sub='$sub' and mon='$mon'");
echo "<table border='2'>";
echo "<th>Rno</th><th>subject</th><th>sem<th>month<th>Total class <th>Percentage";
while($row=mysql_fetch_array($result))
{
echo "<tr>";
$a=$row['tot'];
$b=$row['obt'];
$c=($b*100)/$a;
echo $a;