<?php
require 'database.php';
$query = "SELECT id, date, ponumber FROM so";
$result = $mysqli->query($query) or die(mysqli_error($mysqli));
if ($result) {
echo "<form method='post' action='delete.php'>";
echo "<table cellspacing='0' cellpadding='15' border='1'>
<th >DELETE</th>
<th >VIEW</th>
<th >ID</th>
<th >DATE</th>
<th >PO NUMBER</th>";
while ($row = $result->fetch_object()) {
$date = $row->date ;
$ponumber = $row->ponumber;
$id = $row->id;
//put each record into a new table row with a checkbox
echo "<tr>
<td>
<input type='checkbox' name='checkbox[]' id='checkbox[]' value=$id />
</td>
<td>
$id
</td>
<td>
view
</td>
<td>
$date
</td>
<td>
$ponumber
</td>
</tr>";
}
echo "</table><p><input id='delete' type='submit' class='button' name='delete'
value='Delete Selected Items'/></p></form>";}
?>
i have a sort of an online order form which enable the sales rep to input sales order,
i have done the insert and delete using the code above now i want every row to be a hyperlink so that when they click view it will display only row that has been clicked, in my code above if you click :view" all the detail will display, how can i display only the row that i will click will display the detail of the record!
you need to pass the id in the url and you need to read it if it's there.
e.g.
<?php
require 'database.php';
$query = "SELECT id, date, ponumber FROM so";
/* Edit 1 */
if (!empty($_GET['id'])) {
$query .= " WHERE id = " . mysql_real_escape_string($_GET['id']);
}
/* Edit 1 end */
$result = $mysqli->query($query) or die(mysqli_error($mysqli));
if($result) {
echo "<form method='post' action='delete.php'>";
echo "<table cellspacing='0' cellpadding='15' border='1'>
<th >DELETE</th><th >VIEW</th><th >ID</th><th >DATE</th><th >PO NUMBER</th>";
while ($row = $result->fetch_object()) {
$date = $row->date ;
$ponumber = $row->ponumber;
$id = $row->id;
//put each record into a new table row with a checkbox
echo "<tr>
<td><input type='checkbox' name='checkbox[]' id='checkbox[]' value=$id /></td>
<td>$id</td>
<td>";
/* Edit 2 */
echo "<a href='view.php?id=$id'>view</a>";
/* Edit 2 End */
echo "</td>
<td>$date</td>
<td>$ponumber</td></tr>";
}
echo "</table><p><input id='delete' type='submit' class='button' name='delete' value='Delete Selected Items'/></p></form>";}
?>
A style suggestion:
Don't do/stop doing this:
echo "<form method='post' action='delete.php'>";
echo ...
while
Where what you are echoing is a static string. Instead, do:
?>
<form method='post' action='delete.php'>
...
<?php
while
it's simply easier to read and maintain.
Related
HTML button not selecting correct form value.
The following code selects data and displays it correctly in a html table: fname, lname , customer_id and the last column in the table shows a button labelled more info.
The first part of the code works fine.
<table>
<thead>
<tr>
<th>First Name</th> <th>Last Name</th> <th>Customer ID</th><th>Info</th>
</tr>
</thead>
<tbody>
<tr>
<?php
$sql = "select fname, lname,customer_id from customer_address ";
$result = mysqli_query($conn,$sql);
while($row = mysqli_fetch_assoc($result)){
$fname = $row['fname'];
$lname = $row['lname'];
$customer_id = $row['customer_id'];
echo" <tr>";
echo"<td>$fname</td>";
echo"<td>$lname</td>";
echo"<td>$customer_id</td>";
echo"<td><input type='hidden' name='customer_id' value='$customer_id'>";
echo "<button type='submit' name='submit'>More Info</button></td>" ;
}
echo" </tr>";
?>
</tbody>
</table>
</form>
With the second part of the code, I want to grab the customer_id when the button is clicked and display it below the table(I am going to uses the variable in a subsequent query to display more information later). The button selects the same customer_id no matter which button is clicked, and it is always the last record in the table. I would appreciate any help in correcting my error.
<?php
$ccf=" ";
if(isset($_POST['submit'])){
$ccf = $_POST['customer_id'];
}
echo "Customer Id selected is:$ccf";
?>
Your elements are all inside one form, so there are multiple elements with name='customer_id'. Place each row inside their own separate <form></form>:
<table>
<thead>
<tr>
<th>First Name</th> <th>Last Name</th> <th>Customer ID</th><th>Info</th>
</tr>
</thead>
<tbody>
<?php
$sql = "select fname, lname,customer_id from customer_address";
$result = mysqli_query($conn,$sql);
while($row = mysqli_fetch_assoc($result)){
$fname = $row['fname'];
$lname = $row['lname'];
$customer_id = $row['customer_id'];
echo" <tr>";
echo "<td>$fname</td>";
echo "<td>$lname</td>";
echo "<td>$customer_id</td>";
echo "<td>";
echo "<form action='' method='post'>";
echo "<input type='hidden' name='customer_id' value='$customer_id'>";
echo "<button type='submit' name='submit'>More Info</button>";
echo "</form>";
echo "</td>";
echo" </tr>";
}
?>
</tbody>
</table>
I want to disable the two buttons in a single row if the button will be clicked and won't affect the buttons of another row.
I dont know how to disable an echo button of the table. I want to disable the "Accept" and "Reject" button if one of those was been clicked.I provide a screenshot so that you can easily understand what I mean. Thank you in advance.
Here's my php code. It names as app.php
<?php
//connect to database
$con = mysqli_connect('127.0.0.1','root','');
//select database
mysqli_select_db($con, 'appointment');
//select query
$sql = "SELECT * FROM service";
//Execute the query
$records = mysqli_query($con,$sql)
?>
<html>
<head>
<title>Appointment Schedule</title>
</head>
<body>
<table width = "100%" border = "5px" height = "20%">
<tr align = "left">
<th>First Name</th>
<th>Middle Name</th>
<th>Last Name</th>
<th>Address</th>
<th>Date</th>
<th>Time</th>
<th>Office</th>
<th>Service</th>
<th>Contact No.</th>
<th>Remarks</th>
</tr>
<?php
while($row = mysqli_fetch_array($records))
{
echo "<tr><form action = 'display.php' method = post>";
echo "<input type=hidden name=id value='".$row['ID']."'>";
echo "<td>".$row['fname']."</td>";
echo "<td>".$row['mname']."</td>";
echo "<td>".$row['lname']."</td>";
echo "<td>".$row['address']."</td>";
echo "<td>".$row['date']."</td>";
echo "<td>".$row['time']."</td>";
echo "<td>".$row['office']."</td>";
echo "<td>".$row['services']."</td>";
echo "<td><name = number>".$row['contactno']."</td>";
echo "<td>".$row['remarks']."</td>";
echo "<td><input type =submit value='Accepted' name=accept>";
echo "<td><input type =submit value='Rejected' name=reject>";
echo "</form></tr>";
}
?>
</table>
</body>
</html>
here's my another one php code. It names display.php
<?php
//connect to database
$con = mysqli_connect('127.0.0.1','root','');
//select database
mysqli_select_db($con, 'appointment');
if($_POST['accept'])
{
$sql = "UPDATE service SET remarks = 'Accepted' WHERE ID=$_POST[id]";
}
else if($_POST['reject'])
{
$sql = "UPDATE service SET remarks = 'Rejected' WHERE ID=$_POST[id]";
}
//Execute Query
if(mysqli_query($con,$sql))
header("refresh:1; url=app.php");
else
echo "Unsuccessful";
?>
here's the screenshot of my work
Sample of my database table using php
Kindly try the below code:
Provide the condition to display the buttuon
echo "<td><input type =submit value='Accepted' name=accept>";
echo "<td><input type =submit value='Rejected' name=reject>";
if($row['remarks'] == 'Accepted' || $row['remarks'] == 'Rejected')
{
echo "<td><input type =submit disabled value='Accepted' name=accept>";
echo "<td><input type =submit disabled value='Rejected' name=reject>";
}
I want to let the user sort the table base on what the user wants.
I have two options for this, sort by name or sort by exam.
code
echo "<table border=1 align=center><tr class=style2><td><input type=radio name=sort value='byname'>Sort By Name<td><input type=radio name=sort value='byexam'>Sort By Exam";
$sort = $_POST['name'];
if ($sort == "byname"){
$sort=mysql_query("select * from mst_adminresult order by login ASC",$cn) or die(mysql_error());
while($row=mysql_fetch_row($sort))
echo "<table border=1 align=center><tr class=style2><td>Student Name <td> Test<br> Question <td> Score";
echo "<tr class=style8><td>$row[1] <td align=center> $row[2] <td align=center> $row[3]/20";
echo "</table>";
}else{
$sort=mysql_query("select * from mst_adminresult order by test_id ASC",$cn) or die(mysql_error());
while($row=mysql_fetch_row($sort))
echo "<table border=1 align=center><tr class=style2><td>Exam<td width=300>Student Name<td> Score";
echo "<tr class=style8><td>$row[1] <td align=center> $row[2] <td align=center> $row[3]/20";
echo "</table>";
}
echo "<table border=1 align=center><tr class=style2><td width=300>Student Name <td> Test<br> Question <td> Score";
while($row=mysql_fetch_row($rs))
{
echo "<tr class=style8><td>$row[1] <td align=center> $row[2] <td align=center> $row[3]/20";
}
echo "</table>";
the problem I am encountering is it doesn't function properly. The default arrangement of the data is listed by the latest exam taker to the last. Now what I am aiming for is, if the user checks the by the name option, it will sort by name. for the by exam, it will be listed by exam.
output:
Your input radio button name="sort" so you need to use $_POST['sort'].
You can use input value as database field name so that we can easily use it in query without if...else condition.
echo "<table border=1 align=center><tr class=style2>
<tr><td><input type=radio name='sort' value='byname'>Sort By Name</td>
<td><input type=radio name='sort' value='byexam'>Sort By Exam</td></tr></table>";
$sort = isset($_POST['sort']) ? $_POST['sort'] : "test_id"; // change of $_POST['name'] to $_POST['sort']
$sortQuery = mysql_query("select * from mst_adminresult order by ".$sort." ASC",$cn) or die(mysql_error());
while($row=mysql_fetch_row($sortQuery))
{
echo "<table border=1 align=center><tr class=style2><td>Student Name</td><td>Test<br> Question</td><td>Score</td></tr>";
echo "<tr class=style8><td>$row[1]</td> <td align=center> $row[2]</td> <td align=center> ". ($row[3]/20) ."</td></tr> ";
echo "</table>";
}
echo "<table border=1 align=center><tr class=style2><td width=300>Student Name</td><td> Test<br> Question </td><td> Score</td></tr>";
while($row=mysql_fetch_row($rs))
{
echo "<tr class=style8><td>$row[1]</td> <td align=center> $row[2]</td> <td align=center> ". ($row[3]/20) ."</td></tr> ";
}
echo "</table>";
I have displayed sql table in html table, made a hyperlink near all fields, when i click it the whole field details should be shows in other page(ie; i show only 2 fields of sql in the table and want to show rest in another page).
admin.php
<?php
$con= mysql_connect("localhost","root","");
mysql_select_db("main",$con);
echo"<form action=\"post\" class=\"form-horizontal\" role=\"form\">";
echo "<table width='700' height='150' onclick='myFun(event)'>";
echo" <tr>
<td width='100' align='center'></td>
<td width='100' align='center'><b><u>NAME</u></b></td>
<td width='100' align='left'><b><u>E-MAIL</u></b></td>
</tr>
";
$result=mysql_query("select NAME,EMAIL from admin order by AID");
while($row=mysql_fetch_array($result))
{
echo "<tr>";
echo"<td width='100' align='center'><a href='viewadmin.php?name=".$row['NAME']."'>Select</a></td>";
echo"<td width='100' align='center'>".$row['NAME']."</td>";
echo"<td width='100' align='left'>".$row['EMAIL']."</td>";
echo"</tr>";
}
echo"</table>";
echo"</form> ";
?>
viewadmin.php
<?php
$name = $_GET['name'];
$result=mysql_query("SELECT NAME,DOB,MOB,EMAIL, FROM admin WHERE NAME = $name");
if (false === $result) {
echo mysql_error();
}
else {
$row=mysql_fetch_row($result);
}
echo" <form class=\"form-horizontal\" role=\"form\">
<table width='400'>
<tr>
<td align='left'>Name</td>
<td align='left'>".$row['NAME']."</td>
</tr>
<tr>
<td align='left'>E-mail</td>
<td align='left'>".$row['EMAIL']."</td>
</tr>
<tr>
<td align='left'>D.O.B</td>
<td align='left'>".$row['DOB']."</td>
</tr>
<tr>
<td align='left'>Mobile</td>
<td align='left'>".$row['MOBILE']."</td>
</tr>
<tr>
<td align='left'>Photo</td>
<td ><img src='uploads/grumpy.jpg' height='200' width='200'></td>
</tr>
</table>";
echo"</form> ";
?>
do something like this:
admin.php
$result=mysql_query("select NAME,EMAIL from admin order by AID");
while($row=mysql_fetch_array($result)) {
echo "<tr>";
echo"<td width='100' align='center'><a href='viewadmin.php?name=".$row['NAME']."'>Select</a></td>";
echo"<td width='100' align='center'>".$row['NAME']."</td>";
echo"<td width='100' align='left'>".$row['EMAIL']."</td>";
echo"</tr>";
}
echo"</table>";
and in viewadmin.php
$name = $_GET['name'];
$result=mysql_query("SELECT * FROM admin WHERE name = $name");
$row=mysql_fetch_row($result);
echo " <form class=\"form-horizontal\" role=\"form\">
<table width='400'>
<tr>
<td align='left'>".$row['NAME']."</td>
<td align='left'></td>
</tr>
<tr>
<td align='left'>".$row['EMAIL']."</td>
<td align='left'>...";
first rename the html page by php page, then you can pass the primary key or any key of the row from first page to admin page with the help of GET.
for eg:
first.php
<?php
$result=mysql_query("select ID,NAME,EMAIL from admin order by AID"); while($row=mysql_fetch_array($result)){
?><a hre='admin.php?id="$id=<?php $row[0] ?>"'></a>
<?php
}
?>
and in the admin.php page
you can access the value like
echo $_GET['id'];
stop using MySQL and use MySQLi, this code should work
<?php
$db_connect = mysqli_connect('localhost', 'root', 'pass', 'database');
if (mysqli_connect_errno($db_connect)) {
die('Some error occurred during connection to the database');
}
$name = mysqli_real_escape_string($db_connect,$_REQUEST['name']);
if($stmt = mysqli_prepare($db_connect, 'SELECT * FROM admin WHERE name = ?')){
mysqli_stmt_bind_param($stmt, 's', $name);
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
if(mysqli_num_rows($result) !== 0){
$row = mysqli_fetch_assoc($result);
echo "<form class=\"form-horizontal\" role=\"form\">
<table width='400'>
<tr>
<td align='left'>".$row['NAME']."</td>
<td align='left'></td>
</tr>
<tr>
<td align='left'>".$row['EMAIL']."</td>
<td align='left'>..."
}
else{
echo 'not found';
}
}
else{
trigger_error('error:' . mysqli_errno($db_connect) . mysqli_error($db_connect));
}
?>
Ok, So I am creating a attendance system and I want to mark a student present or absent, this is my code
<?php
if (isset($_POST['submit'])) {
$present = $_POST['present'];
}
$test3= "SELECT * FROM course_attendance, students, courses, attendance WHERE course_attendance.course_id=courses.course_id AND course_attendance.week_id=attendance.week_number_id AND course_attendance.student_id= students.student_id AND courses.course_id='101' AND attendance.week_number_id='2' ";
$result = mysql_query($test3) or die(mysql_error());
echo "</br><table border='1' align='center'><tr> <th><strong>Student ID</strong></th> <th><strong>First Name </strong></th> <th><strong>Last Name</strong></th> <th><strong>Present</strong></th> </tr> ";
while($rows=mysql_fetch_array($result)){
echo"<form name='Biology_lecture11.php' method='post'>";
echo "<tr><td width='100' align='center'>" .$rows['student_id'].
"</td><td width='120' align='center'>" .$rows['fname'].
"</td><td width='120' align='center'>" .$rows['lname'].
"</td><td><input type='text' name='present' value=" .$rows['present'] . ">";
}
echo "</table>";
?>
<input type='submit' name='Submit' value='Submit' >
</form>
<?php
$sql="UPDATE course_attendance SET present='$present' WHERE course_id='101' AND week_id='2' ";
$result=mysql_query($sql);
if($result){
echo "Successfully logged the attendance";
}
else {
echo"ERROR";
}
?>
The problem is , that it does not update the present field in the database, anyone know whats wrong
This should work for you. This will assign each student a unique present value, which is then checked on postback and if set, it is cleaned and used to update the student record in attendance.
I also extracted echo'd HTML in the PHP to HTML, and moved your form outside of your table (it can cause issues in some browsers).
<?php
// Update present values
if (isset($_POST['submit']))
{
// Get a list of student ids to check
$idsResult = mysql_query("SELECT student_id from students");
while($idRow = mysql_fetch_array($idsResult))
{
// if the textbox for this student is set
if(isset($_POST['present'.$idRow['student_id']]) && !empty($_POST['present'.$idRow['student_id']]))
{
// Clean the user input, then escape and update the database
$cleanedPresent = htmlspecialchars(strip_tags($_POST['present'.$idRow['student_id']]));
$sql = "UPDATE course_attendance SET present='".mysql_real_escape_string($present)."' WHERE course_id='101' AND week_id='2' AND student_id=".$idRow['student_id'];
$result = mysql_query($sql);
if($result){
echo "Successfully logged the attendance for ID ".$idRow['student_id'];
}
else {
echo "ERROR updating on ID ".$idRow['student_id'];
}
}
}
}
$test3= "SELECT * FROM course_attendance, students, courses, attendance WHERE course_attendance.course_id=courses.course_id AND course_attendance.week_id=attendance.week_number_id AND course_attendance.student_id= students.student_id AND courses.course_id='101' AND attendance.week_number_id='2' ";
$result = mysql_query($test3) or die(mysql_error());
?>
<form name='Biology_lecture11.php' method='post'>
</br>
<table border='1' align='center'>
<tr>
<th><strong>Student ID</strong></th>
<th><strong>First Name </strong></th>
<th><strong>Last Name</strong></th>
<th><strong>Present</strong></th>
</tr>
<?php
while($rows=mysql_fetch_array($result)){
echo "<tr><td width='100' align='center'>" .$rows['student_id'].
"</td><td width='120' align='center'>" .$rows['fname'].
"</td><td width='120' align='center'>" .$rows['lname'].
"</td><td><input type='text' name='present".$rows['student_id']."' value=" .$rows['present'] . ">";
}
?>
</table>
<input type='submit' name='Submit' value='Submit'>
</form>
Alternative (better) method: If the present value can be set to a simple 0/1 or true/false, then it would be easier to use a checkbox for each student. In postback, you can then retrieve an array of values from checking each checkbox indicating students who are present, and then update the database table in one query. That also prevents from malicious text input.
Alternative code:
<?php
// Update present values
if (isset($_POST['submit']))
{
// Get a list of student ids to check
$idsResult = mysql_query("SELECT student_id from students");
$presentIds = array();
$absentIds = array();
while($idRow = mysql_fetch_array($idsResult))
{
// If the student's checkbox is checked, add it to the presentIds array.
if(isset($_POST['present'.$idRow['student_id']]))
{
$presentIds[] = $idRow['student_id'];
}
else
{
$absentIds[] = $idRow['student_id'];
}
}
// Convert array to string for query
$idsAsString = implode(",", $presentIds);
// You can set present to whatever you want. I used 1.
$sql = "UPDATE course_attendance SET present='1' WHERE course_id='101' AND week_id='2' AND student_id IN (".$idsAsString.")";
$result = mysql_query($sql);
if($result){
echo "Successfully logged the attendance for IDs ".$idsAsString;
}
else {
echo "ERROR updating on IDs ".$idsAsString;
}
// OPTIONAL: Mark absent students as '0' or whatever other value you want
$absentIdsAsString = implode(",", $absentIds);
// You can set present to whatever you want. I used 1.
$absentQuery = "UPDATE course_attendance SET present='0' WHERE course_id='101' AND week_id='2' AND student_id IN (".$absentIdsAsString.")";
$absentResult = mysql_query($absentQuery);
if($absentResult){
echo "Successfully logged absence for IDs ".$absentIdsAsString;
}
else {
echo "ERROR updating absence on IDs ".$absentIdsAsString;
}
}
$test3= "SELECT * FROM course_attendance, students, courses, attendance WHERE course_attendance.course_id=courses.course_id AND course_attendance.week_id=attendance.week_number_id AND course_attendance.student_id= students.student_id AND courses.course_id='101' AND attendance.week_number_id='2' ";
$result = mysql_query($test3) or die(mysql_error());
?>
<form name='Biology_lecture11.php' method='post'>
</br>
<table border='1' align='center'>
<tr>
<th><strong>Student ID</strong></th>
<th><strong>First Name </strong></th>
<th><strong>Last Name</strong></th>
<th><strong>Present</strong></th>
</tr>
<?php
while($rows=mysql_fetch_array($result)){
echo "<tr><td width='100' align='center'>" .$rows['student_id'].
"</td><td width='120' align='center'>" .$rows['fname'].
"</td><td width='120' align='center'>" .$rows['lname'].
"</td><td><input type='checkbox' name='present".$rows['student_id']."' ";
// NOTE: REPLACE 1 with whatever value you store in the database for being present.
// I used 1 since the update at the top of the code uses 0 and 1.
if($rows['present']=='1')
{
echo "checked='checked' ";
}
// With a checkbox, you don't need to assign it a value.
echo "value=" .$rows['present'];
echo ">";
}
?>
</table>
<input type='submit' name='Submit' value='Submit'>
</form>
One mistake I see is, that you put this:
echo"<form name='Biology_lecture11.php' method='post'>";
in your while-loop. So it is put out more than one time. Try writing that part in the row before your loop.
A couple of issues I see:
1: You're UPDATE code is running every time the page is loaded. Move you update block into the if (isset($_POST['submit'])) {} block.
2: When you print out the students, you create an input called "present" for every student. If you were to fill this in and submit the data, only the last field will be added to the database.
3: You're not updating a specific student. I would change the input field to a checkbox and name it "present[$rows[student_id]]".
Then, once the page is being processed, loop through the key/values of $_POST['present']. and update any students that are in it.
foreach (array_keys($_POST['present']) as $student_id) {
if (is_numeric($student_id)) {
$sql="UPDATE course_attendance SET present='true' WHERE course_id='101' AND week_id='2' and student_id='$student_id'";
}
}
You'll have to modify the UPDATE if the attendance table isn't automatically filled in with students. If every student isn't already there, you'll have to run a query to see if they exist. If they don't insert the row. If they do, update the row.
4: Move the opening tag to before the opening of the table and OUTSIDE of the student loop.
Two things to take in consideration: First, you have form element dupplication. As the comments above said, take out the line
echo"<form name='Biology_lecture11.php' method='post'>";
from the loop.
Second, the UPDATE statatement updates all the students, you need a WHERE token in your SQL statement. Something like this:
<?php
if (isset($_POST['submit'])) {
$present = $_POST['present'];
}
$test3= "SELECT * FROM course_attendance, students, courses, attendance WHERE course_attendance.course_id=courses.course_id AND course_attendance.week_id=attendance.week_number_id AND course_attendance.student_id= students.student_id AND courses.course_id='101' AND attendance.week_number_id='2' ";
$result = mysql_query($test3) or die(mysql_error());
echo "</br><table border='1' align='center'><tr> <th><strong>Student ID</strong></th> <th><strong>First Name </strong></th> <th><strong>Last Name</strong></th> <th><strong>Present</strong></th> </tr> ";
echo"<form name='Biology_lecture11.php' method='post'>";
while($rows=mysql_fetch_array($result)){
echo "<tr><td width='100' align='center'>" .$rows['student_id'].
"</td><td width='120' align='center'>" .$rows['fname'].
"</td><td width='120' align='center'>" .$rows['lname'].
"</td><td><input type='text' name='present' value=" .$rows['present'] . ">";
}
echo "</table>";
?>
<input type='submit' name='Submit' value='Submit' >
</form>
<?php
$sql="UPDATE course_attendance SET present='$present' WHERE course_id='101' AND week_id='2' AND student_id = the_student_id";
$result=mysql_query($sql);
if($result){
echo "Successfully logged the attendance";
}
else {
echo"ERROR";
}
?>
Hope it helps!
you have taken a form inside table tag and inside while loop this will not work, here is correct code.
<?php
if (isset($_POST['submit'])) {
$present = $_POST['present'];
$sql="UPDATE course_attendance SET present='$present' WHERE course_id='101' AND week_id='2' ";
$result=mysql_query($sql);
if($result) {
echo "Successfully logged the attendance";
}
else {
echo"ERROR";
}
}
?>
<form name='Biology_lecture11.php' method='post'>
<table border="1" align="center">
<tr>
<th><strong>Student ID</strong></th>
<th><strong>First Name </strong></th>
<th><strong>Last Name</strong></th>
<th><strong>Present</strong></th>
</tr>
<?php
$test3= "SELECT * FROM course_attendance, students, courses, attendance WHERE course_attendance.course_id=courses.course_id AND course_attendance.week_id=attendance.week_number_id AND course_attendance.student_id= students.student_id AND courses.course_id='101' AND attendance.week_number_id='2' ";
$result = mysql_query($test3) or die(mysql_error());
while($rows=mysql_fetch_array($result)) {
echo "<tr><td width='100' align='center'>" .$rows['student_id']."</td>
<td width='120' align='center'>" .$rows['fname']."</td>
<td width='120' align='center'>" .$rows['lname']."</td>
<td><input type='text' name='present' value=" .$rows['present']."></td></tr>";
}
echo "</table>";
?>
<input type='submit' name='Submit' value='Submit' >
</form>