0% found this document useful (0 votes)
284 views5 pages

PHP Lab Program For MCA

This document outlines a PHP program to record student attendance and view attendance reports highlighting shortages. It includes code for connecting to a database, building forms to enter attendance by semester, month, subject and student, and inserting records. It also shows code for a view attendance form and query to retrieve records and display totals, with percentages below 75% shown in cyan to highlight shortages.

Uploaded by

shylesh86
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
284 views5 pages

PHP Lab Program For MCA

This document outlines a PHP program to record student attendance and view attendance reports highlighting shortages. It includes code for connecting to a database, building forms to enter attendance by semester, month, subject and student, and inserting records. It also shows code for a view attendance form and query to retrieve records and display totals, with percentages below 75% shown in cyan to highlight shortages.

Uploaded by

shylesh86
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Write a simple php program to enter attendance and view attendance with shortage being

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>";

echo " <select name='sem' onchange=\"reload3(this.form)\"><option value=''>Select


one</option>";?>
<option value="1">First Semester</option>
<option value="2">Second Semester</option>
<option value="3">Third Semester</option>
<option value="4">Fourth Semester</option>
<option value="5">Fifth Semester</option>
<option value="6">Sixth Semester</option>
</select>
<tr><td>
rno<td>

<?php echo "<select name='rno' ><option value=''>Select one</option>";?>


<option value="101">101</option>
<option value="102">102</option>
<option value="103">103</option>
<option value="104">104</option>
<option value="105">105</option>

</select>

<tr><td>
Month<td>

<?php echo "<select name='mon' ><option value=''>Select one</option>";?>


<option value="January">January</option>
<option value="February">February</option>
<option value="March">March</option>
<option value="April">April</option>
<option value="May">May</option>
<option value="June">June</option>
<option value="July">July</option>
<option value="August">August</option>
<option value="September">September</option>
<option value="October">October</option>
<option value="November">November</option>
<option value="December">December</option>
<option value="Final">Final</option>
</select>

<tr><td>

<tr><td>
Subject<td>

<?php echo "<select name='sub' ><option value=''>Select one</option>";?>


<option value="s1">sub1</option>
<option value="s2">sub2</option>
<option value="s3">sub3</option>

</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']))
{

$extract1=mysql_query("SELECT * FROM attendance WHERE rno='$rno' and sem='$sem' and


sub='$sub' and mon='$mon'");
$count2=mysql_num_rows($extract1);
//echo "lllll".$count2;
if($count2== 0)
{
$sql="INSERT INTO attendance
VALUES('','$rno','$sem','$sub','$mon','$tot','$obt')";

$result=mysql_query($sql) or die(mysql_error());

echo "<table class=table align='center' border=2 bgcolor='white' cellspacing='0'>";

}
?>
</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>";

echo " <select name='sem' onchange=\"reload3(this.form)\"><option value=''>Select


one</option>";?>
<option value="1">First Semester</option>
<option value="2">Second Semester</option>
<option value="3">Third Semester</option>
<option value="4">Fourth Semester</option>
<option value="5">Fifth Semester</option>
<option value="6">Sixth Semester</option>
</select>
<tr><td>
Month<td>

<?php echo "<select name='mon' ><option value=''>Select one</option>";?>


<option value="January">January</option>
<option value="February">February</option>
<option value="March">March</option>
<option value="April">April</option>
<option value="May">May</option>
<option value="June">June</option>
<option value="July">July</option>
<option value="August">August</option>
<option value="September">September</option>
<option value="October">October</option>
<option value="November">November</option>
<option value="December">December</option>
<option value="Final">Final</option>
</select>

<tr><td>

<tr><td>
Subject<td>

<?php echo "<select name='sub' ><option value=''>Select one</option>";?>


<option value="s1">sub1</option>
<option value="s2">sub2</option>
<option value="s3">sub3</option>

</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;

echo "<td>".$row['rno']." </td>";


echo "<td>".$row['sub']." </td>";
echo "<td>".$row['sem']." </td>";
echo "<td>".$row['mon']." </td>";
echo "<td>".$row['tot']." </td>";
if($c<75)
echo "<td> <font color=cyan>".$c." </td>";
else
echo "<td> <font color=black>".$c." </td>";
}
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy