Pass certain table cell values to SQL update query - php

I feel stuck with a bit unusual situation for me up until now ... I constructed a HTML table that shows quantities from different locations by reading and rows from SQL DB into a $locations variable that is essentially an array - here's the code:
while ($location = mssql_fetch_array($locations)){
echo"
<tr>
<td style='text-align:center; padding-left: 2px; padding-right: 2px'>$location[1]</td>
<td style='text-align:center; padding-left: 2px; padding-right: 2px'>$location[2]</td>
<td width='50' style='text-align:center; padding-left: 2px; padding-right: 2px'><input type='number' style='border:none;text-align:center;' class='input' name='qty_to_add[]' type='text' value='' min='1' max='999'></td>
</tr>";
};
But the real problem is how do I read only cells in the third column to the right, that have values imputed and pass only those to an update query that will further update only those rows that contain locations POL_12 (15 pcs + 5 more) and POL_54 (30 pcs + 7 more)?
I need to do this in a procedural way, since I am not yet familiar with OOP and PDO (but I am striving to learn it soon) :/
Please advise, all suggestions are welcome! Thank Y'all!

In this scenario, following Barmar's advice (because it seemed most familiar to me in this moment) - using hidden fields in a form combined with for loop worked like a charm!
<form method="post" enctype="multipart/form-data">
<table style="width:100%" border="2">
<tr>
<th style="text-align:center; padding-left: 2px; padding-right: 2px">Location</th>
<th style="text-align:center; padding-left: 2px; padding-right: 2px">Qty</th>
<th style="text-align:center; padding-left: 2px; padding-right: 2px">Qty to add</th>
</tr>
<?php
$locations = mssql_query("my query for reading item name, location and quantity per location ");
while ($location = mssql_fetch_array($locations))
{
echo"
<tr>
<input style='border:none;text-align:center;' class='input' name='location_id[]' type='hidden' value='$location[0]'>
<input style='border:none;text-align:center;' class='input' name='item_id[]' type='hidden' value='$location[3]'>
<td style='text-align:center; padding-left: 2px; padding-right: 2px'>$location[1]</td>
<td width='2' style='text-align:center; padding-left: 2px; padding-right: 2px'><input type='number' style='border:none;text-align:center;' class='input' name='current_qty[]' type='text' value='";if (!isset($location[2])) {echo "0";} else {echo $location[2];}; echo "'></td>
<td width='50' style='text-align:center; padding-left: 2px; padding-right: 2px'><input type='number' style='border:none;text-align:center;' class='input' name='qty_to_add[]' type='text' value='0' min='0' max='999'></td>
</tr>";
};
?>
</table></br>
<input id="post" class="search" name="submit" type="submit" value="POST" style="position: relative"></br>
</form>
<?php
if (isset($_POST['submit']))
{
$location_id = $_POST['location_id'];
$ite_id = $_POST['item_id'];
$curr_qty = $_POST['current_qty'];
$added_qty = $_POST['qty_to_add'];
$rowCount = count($_POST['location_id']);
for ($i = 0; $i < $rowCount; $i++)
{
if ($added_qty > 0)
{
$query = mssql_query("update [my-table-name] set qty_per_location = cast('$curr_qty[$i]' as decimal (5,2)) + cast('$added_qty[$i]' as decimal (5,2)) where item_id = $item_id[$i] and item_location_id = $location_id[$i]");
echo "<br/><br/><span>Data inserted to DB successfully!</span>";
}
}
}
?>
I don't want to sound disrespectful to others, that suggested possible solutions - I chose this solution merely because it was understandable for my current novice level of knowledge! Instead a big shoutout to all that sacrificed a lil' bit their time to contribute. Thank y'all!

Related

Adding CSS class in form that posts to PHP breaks query

I am a beginner to coding... Something strange happens when I enter a CSS class to a form that posts data to same php file that executes mysqli query. Everything goes well until I add to the form. When I do this, I don't get an error, but browser reads: search.php?submitted=true&category=firstname&criteria=hassan&submitted=Submit. I also don't get any results back.
When I don't have the css class added, it works fine, url doesn't read the above and database results come back. Any help as to why this happens and what I can do to fix it?
Apologies in advance for strange way of adding css. Using purecss.io but import from yahoo cdn doesn't work, also uploading to server doesn't work. Only way I get it to work is by adding the css code directly into file.
<html>
<head>
<title>pageName</title>
<style type="text/css">
table {
background-color: #ADD8E6;
border: 1px solid black;
font-family: Arial; font-size: 14px;
}
th {
text-align: left;
}
.pure-form input[type=text],.pure-form input[type=password],.pure-form input[type=email],.pure-form input[type=url],.pure-form input[type=date],.pure-form input[type=month],.pure-form input[type=time],.pure-form input[type=datetime],.pure-form input[type=datetime-local],.pure-form input[type=week],.pure-form input[type=number],.pure-form input[type=search],.pure-form input[type=tel],.pure-form input[type=color],.pure-form select,.pure-form textarea{padding:.5em .6em;display:inline-block;border:1px solid #ccc;box-shadow:inset 0 1px 3px #ddd;border-radius:4px;vertical-align:middle;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.pure-form input:not([type]){padding:.5em .6em;display:inline-block;border:1px solid #ccc;box-shadow:inset 0 1px 3px #ddd;border-radius:4px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.pure-form input[type=color]{padding:.2em .5em}.pure-form input[type=text]:focus,.pure-form input[type=password]:focus,.pure-form input[type=email]:focus,.pure-form input[type=url]:focus,.pure-form input[type=date]:focus,.pure-form input[type=month]:focus,.pure-form input[type=time]:focus,.pure-form input[type=datetime]:focus,.pure-form input[type=datetime-local]:focus,.pure-form input[type=week]:focus,.pure-form input[type=number]:focus,.pure-form input[type=search]:focus,.pure-form input[type=tel]:focus,.pure-form input[type=color]:focus,.pure-form select:focus,.pure-form textarea:focus{outline:0;border-color:#129FEA}.pure-form input:not([type]):focus{outline:0;border-color:#129FEA}.pure-form input[type=file]:focus,.pure-form input[type=radio]:focus,.pure-form input[type=checkbox]:focus{outline:thin solid #129FEA;outline:1px auto #129FEA}.pure-form .pure-checkbox,.pure-form .pure-radio{margin:.5em 0;display:block}.pure-form input[type=text][disabled],.pure-form input[type=password][disabled],.pure-form input[type=email][disabled],.pure-form input[type=url][disabled],.pure-form input[type=date][disabled],.pure-form input[type=month][disabled],.pure-form input[type=time][disabled],.pure-form input[type=datetime][disabled],.pure-form input[type=datetime-local][disabled],.pure-form input[type=week][disabled],.pure-form input[type=number][disabled],.pure-form input[type=search][disabled],.pure-form input[type=tel][disabled],.pure-form input[type=color][disabled],.pure-form select[disabled],.pure-form textarea[disabled]{cursor:not-allowed;background-color:#eaeded;color:#cad2d3}.pure-form input:not([type])[disabled]{cursor:not-allowed;background-color:#eaeded;color:#cad2d3}.pure-form input[readonly],.pure-form select[readonly],.pure-form textarea[readonly]{background-color:#eee;color:#777;border-color:#ccc}.pure-form input:focus:invalid,.pure-form textarea:focus:invalid,.pure-form select:focus:invalid{color:#b94a48;border-color:#e9322d}.pure-form input[type=file]:focus:invalid:focus,.pure-form input[type=radio]:focus:invalid:focus,.pure-form input[type=checkbox]:focus:invalid:focus{outline-color:#e9322d}.pure-form select{height:2.25em;border:1px solid #ccc;background-color:#fff}.pure-form select[multiple]{height:auto}.pure-form label{margin:.5em 0 .2em}.pure-form fieldset{margin:0;padding:.35em 0 .75em;border:0}.pure-form legend{display:block;width:100%;padding:.3em 0;margin-bottom:.3em;color:#333;border-bottom:1px solid #e5e5e5}.pure-form-stacked input[type=text],.pure-form-stacked input[type=password],.pure-form-stacked input[type=email],.pure-form-stacked input[type=url],.pure-form-stacked input[type=date],.pure-form-stacked input[type=month],.pure-form-stacked input[type=time],.pure-form-stacked input[type=datetime],.pure-form-stacked input[type=datetime-local],.pure-form-stacked input[type=week],.pure-form-stacked input[type=number],.pure-form-stacked input[type=search],.pure-form-stacked input[type=tel],.pure-form-stacked input[type=color],.pure-form-stacked input[type=file],.pure-form-stacked select,.pure-form-stacked label,.pure-form-stacked textarea{display:block;margin:.25em 0}.pure-form-stacked input:not([type]){display:block;margin:.25em 0}.pure-form-aligned input,.pure-form-aligned textarea,.pure-form-aligned select,.pure-form-aligned .pure-help-inline,.pure-form-message-inline{display:inline-block;*display:inline;*zoom:1;vertical-align:middle}.pure-form-aligned textarea{vertical-align:top}.pure-form-aligned .pure-control-group{margin-bottom:.5em}.pure-form-aligned .pure-control-group label{text-align:right;display:inline-block;vertical-align:middle;width:10em;margin:0 1em 0 0}.pure-form-aligned .pure-controls{margin:1.5em 0 0 11em}.pure-form input.pure-input-rounded,.pure-form .pure-input-rounded{border-radius:2em;padding:.5em 1em}.pure-form .pure-group fieldset{margin-bottom:10px}.pure-form .pure-group input,.pure-form .pure-group textarea{display:block;padding:10px;margin:0 0 -1px;border-radius:0;position:relative;top:-1px}.pure-form .pure-group input:focus,.pure-form .pure-group textarea:focus{z-index:3}.pure-form .pure-group input:first-child,.pure-form .pure-group textarea:first-child{top:1px;border-radius:4px 4px 0 0;margin:0}.pure-form .pure-group input:first-child:last-child,.pure-form .pure-group textarea:first-child:last-child{top:1px;border-radius:4px;margin:0}.pure-form .pure-group input:last-child,.pure-form .pure-group textarea:last-child{top:-2px;border-radius:0 0 4px 4px;margin:0}.pure-form .pure-group button{margin:.35em 0}.pure-form .pure-input-1{width:100%}.pure-form .pure-input-2-3{width:66%}.pure-form .pure-input-1-2{width:50%}.pure-form .pure-input-1-3{width:33%}.pure-form .pure-input-1-4{width:25%}.pure-form .pure-help-inline,.pure-form-message-inline{display:inline-block;padding-left:.3em;color:#666;vertical-align:middle;font-size:.875em}.pure-form-message{display:block;color:#666;font-size:.875em}#media only screen and (max-width :480px){.pure-form button[type=submit]{margin:.7em 0 0}.pure-form input:not([type]),.pure-form input[type=text],.pure-form input[type=password],.pure-form input[type=email],.pure-form input[type=url],.pure-form input[type=date],.pure-form input[type=month],.pure-form input[type=time],.pure-form input[type=datetime],.pure-form input[type=datetime-local],.pure-form input[type=week],.pure-form input[type=number],.pure-form input[type=search],.pure-form input[type=tel],.pure-form input[type=color],.pure-form label{margin-bottom:.3em;display:block}.pure-group input:not([type]),.pure-group input[type=text],.pure-group input[type=password],.pure-group input[type=email],.pure-group input[type=url],.pure-group input[type=date],.pure-group input[type=month],.pure-group input[type=time],.pure-group input[type=datetime],.pure-group input[type=datetime-local],.pure-group input[type=week],.pure-group input[type=number],.pure-group input[type=search],.pure-group input[type=tel],.pure-group input[type=color]{margin-bottom:0}.pure-form-aligned .pure-control-group label{margin-bottom:.3em;text-align:left;display:block;width:100%}.pure-form-aligned .pure-controls{margin:1.5em 0 0}.pure-form .pure-help-inline,.pure-form-message-inline,.pure-form-message{display:block;font-size:.75em;padding:.2em 0 .8em}}
</style>
</head>
<body>
<h1>MEMBERS SEARCH</h1>
<form class="pure-form">
<form method="post" action="search.php">
<input type="hidden" name="submitted" value="true"/>
<label> Search Category:
<select name="category">
<option value="firstname">First NAME</option>
<option value="lastname">Last NAME</option>
</select>
</label>
<label> Search Criteria:<input type="text" name="criteria" /></label>
<input type="submit" name="submitted" />
</form>
<?php
if (isset($_POST['submitted'])){
// connect to the DB
include('connect.php');
$category = mysqli_real_escape_string($con, $_POST['category']);
$criteria = mysqli_real_escape_string($con, $_POST['criteria']);
$query = "SELECT * FROM Customers WHERE firstname LIKE '%" . $criteria ."%'";
$result = mysqli_query($con, $query);
$num_rows = mysqli_num_rows($result);
echo "$num_rows results found";
while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
?>
<table>
<tr>
<td width="300" ><font face="Arial Black" size="2"><?php echo $row['firstname']?> <?php echo $row['lastname']?></font></td>
</tr>
</table>
<table>
<tr>
<td width="100"><b>Licence #</b></td>
<td width="3">:</td>
<td width="120"><?php echo $row['licencenr']?></td>
</tr>
<tr>
<td width="100"><b>Birthday</b></td>
<td width="3">:</td>
<td width="120"><?php echo $row['birth']?></td>
</tr>
<tr>
<td width="100"><b>Age</b></td>
<td width="3">:</td>
<td width="120"><?php echo $row['age']?></td>
</tr>
<td width="120"> </td>
</tr>
</table>
<br>
<?php
}
}
?>
</body>
</html>
I found the solution...
instead of adding
<form class="pure-form">
i deleted
<form class="pure-form">
and changed
<form method="post" action="search.php">
to
<form method="post" class="pure-form" action="search.php">

PHP Variable not Echoing

Evening All, just trying to figure out why some of my variables are not echoing from my MYSQL database. At first they were going to be Session variables of which i found did not work, so then i changed to a mysql query on my invoice page
$OrderID = $_SESSION[OrderID];
$LName = mysql_result(mysql_query("SELECT LName FROM customers WHERE Username = '$Username'"), 0);
$Fname = mysql_result(mysql_query("SELECT FName FROM customers WHERE Username = '$Username'"), 0);
$Date = mysql_result(mysql_query("SELECT Date FROM orders WHERE OrderID = '$OrderID'"), 0);
My Queries above. Order ID and Date are working, yet Lname and Fname are not where everything is named correctly as they are in the database.
Full Code below of where i am trying to echo them.
<div id='containter' style='position:absolute;width:750px;height:800px; left:50% ; margin-left: -375px; border-style: solid;border-width: 1px;'>
<div id='heading' style='position:absolute;width:650px;height:100px; left:50% ; margin-left: -325px;top:20px; border-style: solid;border-width: 1px;'>
<div style='position:absolute;left:500px;text-align:center;font-size:36px;'> <p>INVOICE </p></div>
<div style='position:absolute;text-align:center;font-size:38px;width:250px;left:-20px;'> OzScopes</div>
<div style='position:absolute;text-align:center;font-size:16px;width:250px;left:-37px;top:45px;'> ozscopes.com.au</div>
<div id='headingbottom' style='position:absolute;width:100%;height:20px;top:80px;'>
<table>
<tr>
<td style='position:absolute;left:5%;'>Invoice Number </td>
<td style='position:absolute;left:25%;'> <?php echo $OrderID;?> </td>
<td style='position:absolute;left:77%;'><?php echo $Date ;?></td>
</tr>
</table>
</div>
</div>
<div id='invoicecontent' style='position:absolute;width:650px;height:600px; left:50% ; margin-left: -325px;top:140px; border-style: solid;border-width: 1px;'>
<div id='information'>
<div id='customerinfo' style='position:absolute;width:255px;height:75px;top:-210px;padding:10px; border-bottom: 2px solid;border-right:1px solid; display:inline'>
<table>
<tr>
<th>Customer Information</th>
</tr>
<tr>
<td> <?php echo $LName;?> lnametest</td>
</tr>
</table>
</div>
<div id='mailinginfo' style='position:absolute;width:355px;height:75px;left:275px;top:-210px;padding:10px;border-bottom: 2px solid; display:inline'>
Mailing Information
</div>
</div>
<div id='products' style='position:absolute;top:97px;width:650px;height:503px;'>
<?php
echo "<table border=\"0\" cellspacing=\"0\" padding=\"0\" width=\"650px\">";
echo "<tr style='font-weight: bold; font-size:16px;'>";
echo "<td colspan=\"2\" align=\"center\" style='border-bottom: 2px solid;font-family:'Ek Mukta';color:#464d48;'>Description</td>";
echo "<td align=\"left\" style='border-bottom: 2px solid;font-family:'Ek Mukta';color:#464d48;'>Quantity</td>";
echo "<td colspan=\"3\" align=\"center\" style='border-bottom: 2px solid ;font-family:'Ek Mukta';color:#464d48;'>Price (Per Unit)</td>";
echo "<td align=\"center\" style='border-bottom: 2px solid;font-family:'Ek Mukta';color:#464d48;'>Total</td>";
echo "</tr>";
echo "</table>";
?>
</div>
<div id='payment'>
</div>
</div>
</div>
Where are you getting $Username? should you get it from the session first?
Like so:
$Username = $_SESSION[Username];
otherwise this string is empty and the select statement will come back as empty, because the where clause was based on username = $Username (which in this case is empty).
Get username of the session variable first, then use it in where clause. Apart from that, as others have said, please avoid using mysql queries, use mysqli instead.
Hope it helps.

MYSQL fetching rows to different tables

I'm here with following problem. I have table with multiple records. Each row represents news of some kind, so I need to distinguish one from the another. The way to do that, is to make a table for each of these news(or a wrapper of some kind), however I encoutred a problem with fetching each result to each table(wrapper).
I can't figure out how to tell SQL to put the record separatley. Below is chunk of my code, as well as the design for the table.
.news{
width:400px;
height:auto;
border: 1px solid red;
float:left;
}
.news tr:first-child{
font-weight: bold;
height:40px;
text-align: center;
}
.news tr:last-child{
background-color: whitesmoke;
height: 200px;
padding-bottom: auto;
text-align: center;
}
.details td{
width:200px;
height: 40px;
text-align: center;
}
echo "<table class='news'>";
while ($row = mysqli_fetch_array($result)) {
echo "<tr>
<td colspan='2'>
$row[0]
</td>
</tr>
<tr class='details'>
<td>
$row[1]
</td>
<td>
$row[2]
</td>
</tr>
<tr>
<td colspan='2'>
$row[3]
</td>
</tr>";
echo "</table>";
}
$query = " SELECT headline, date, concat (firstName,' ',lastName), body FROM "
. "school_info natural join teachers ORDER BY id_school_inf DESC LIMIT 2;";
$result = mysqli_query($conn, $query);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^This is my query. There is a limit, so i can always fetch latest (let's say last 5) news.
Any help would be much appreciated
You need to create a separate table for every type of record you have? Simple enough, if you order your records by the type:
SELECT * FROM whatever ORDER BY type_of_record
then
$previous = null;
while(... fetch from db ...) {
if ($row['type'] != $previous) {
... got new record type, start new table
}
... display row
$previous = $row['type']; // store current type for comparison later
}

Order Results By Row Valuation Calculation Answer

I have the following query providing me with a table full of the correct descriptions and figures:
$result = mysqli_query($con,"SELECT * FROM b_sale_basket WHERE ORDER_ID=$ID");
$total=0;
while($row = mysqli_fetch_array($result))
{
$quantity = $row['QUANTITY'];
$description = $row['NAME'];
$unitprice = $row['PRICE'];
$lineprice = $row['PRICE']*$row['QUANTITY'];
$total=$total+$lineprice;
$tbl_header = '<table style="width: 650px;" cellspacing="0" cellpadding="5">';
$tbl_footer = '</table>';
$tbl = '';
$tbl .= '
<tr>
<td style="width: 50px; text-align: left; border-bottom: 0.1em solid #808080;"><p style="color:#808080;">'.number_format($quantity,0).'</p></td>
<td style="width: 350px; border-bottom: 0.1em solid #808080;"><p style="color:#808080;">'.$description.'</p></td>
<td style="width: 125px; text-align:right; border-bottom: 0.1em solid #808080;"><p style="color:#808080;">'.number_format($unitprice,2).'</p></td>
<td style="width: 125px; text-align:right; border-bottom: 0.1em solid #808080;" align="right" ><p style="color:#808080;">'.number_format($lineprice,2).'</p></td>
</tr>
';
As you will be able to see the $lineprice is calculated by:
$lineprice = $row['PRICE']*$row['QUANTITY'];
Now I would like to order the table results based on the value in this field. I've tried:
SELECT * FROM b_sale_basket WHERE ORDER_ID=$ID ORDER BY '$lineprice' ASC
But that doesn't work. How could I order the results in the table by this column?
Thank you in advance,
Andy
ORDER BY PRICE * QUANTITY
Ordering by a fixed number, like you're trying won't work, because the DB will have NO idea what field(s) to compare that fixed value against. But if you do the multiplication within the deb, as in the above snippet, you'll get your expected sort order.
SELECT quantity * price as total FROM b_sale_basket ORDER BY total;

want to insert in attendence first time not update it

hi this is my code which updates an attendance system, but I dont know how to insert attendance for first time. Where should I use insert query? it also shows error and not updating the table. Somebody please guide me
<?php
$connection=mysql_connect("localhost","root","") ordie(mysql_error()
$db=mysql_select_db("Project") or die(mysql_error());
$sql = "SELECT Fac_name FROM Faculty ORDER BY Fac_name ASC ";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
?>
<form name="Attendence" method="post" action="A.php">
<table style="text-align: left; padding: 5px;" cellpadding="0px" cellspacing="0px">
<tbody>
<tr>
<th style="text-align: center; padding: 5px; border: 1px #000000 solid;">Faculty Name</th>
<th style="text-align: center; padding: 5px; border: 1px #000000 solid;">Abesent</th>
<th style="text-align: center; padding: 5px; border: 1px #000000 solid;">Present</th>
<th style="text-align: center; padding: 5px; border: 1px #000000 solid;">Total present</th>
</tr>
<?php
while($rows=mysql_fetch_array($result)) {
?>
<tr>
<td class="table1">
<? $id[] = $rows['Fac_name']; ?><? echo $rows['Fac_name'];?>
</td>
<td class="table1">
<input name="date[<? echo $rows['Fac_name']; ?>]" type="text" >
</td>
<td id="present">
<input type="radio" name="Present[<? echo $rows['Fac_name']; ?>]" checked="checked" >Present
</td>
<td id="absent">
<input type="radio" name="Absent[<? echo $rows['Fac_name']; ?>]" value="ABSENT">Absent
</td>
<td style="text-align: left; padding: 5px; border: 1px #000000 solid; height: 33px;"></td>
</tr>
<?php }?>
<tr>
<td colspan="7" style="vertical-align:middle; text-align: center;">
<br><br>
<input id="Submit" type="submit" name="Submit" value="Insert" style="text-align: center; background-color: #000000; color: #ffffff; border: 1px #000000 solid;">
</td>
</tr>
</tbody>
</table>
</form>
<?php
if(isset($_POST['Submit'])) {
foreach($_POST['Present'] as $id => $value) {
$date=$_POST['date'];
$present=$_POST['Present'];
$absent=$_POST['Absent'];
$sql = "INSERT INTO Attendence(Fac_name, date, Present, Absent) VALUES ('".$id."', '$date[$value]', '$present[$value]', '$absent[$value]', '".$value."') ";
$result = mysql_query($sql);
}
}
if($result) {
//header("location:A.php");
} else {
//print_r ($_POST);
echo "Your entry is not completed at this time.............";
}
if(isset($_POST['submitattend'])) {
set_time_limit(0);
$class1 = $_SESSION['bra'];
$q3 = mysql_query("Select Id from `Faculty` order by `Id` ASC"); // get all roll numbers
$count = mysql_num_rows($q3);
$j = 1;
while($q4 = mysql_fetch_array($q3)) {
if(isset($_POST['chk'.$j])) {
$v2 = $q7['finalattend']+1; //total attendance of student
$v3 = $q7['totalattend']+1; //total attendance taken by teacher
mysql_query("UPDATE `Attendence` SET `finalattend`='".$v2."', `totalattend`='".$v3."' where `attenduser`='".$v1."'") or die(mysql_error());
} else {
$v2=$q7['totalattend']+1;
mysql_query("UPDATE `Attendence` SET `totalattend`='".$v2."' where `attenduser`='".$v1."'") or die(mysql_error());
}
$j=$j+1;
}
header("Location: 12.html"); //logout after taking attendance..
}
?>
$date_value = $date[$value];
$present_value = $present[$value];
$absent_value = $absent[$value];
$check_result = mysql_query("selct count(*) from Attendence where Fac_name = '$id' AND date = '$date_value' AND Present = '$present_value' AND Absent = '$absent_value' ");
if($check_result == 0)
{
// insert query
}
else
{
// update query
}
I think your INSERT query line has Syntax error Please correct it . You have only three row names - Fac_name, date, Present, Absent but are inserting 5 values. Besides that quotes are not used correctly

Categories