I'm trying to teach myself php and mysql and I'm having trouble with a form I'm working on for a football pool I'm trying to put together. I'm looking for a little help on the best way to submit the data from this form. The form gets data from my database and repeats for the appropriate number of rows. Upon submitting the form each row should be inserted or updated to the database. The data that needs to be submitted is: userid, gameid, pick, and tbPoints.
The form is a little rough as I have not finished it yet. I just cant seem to get the form to submit each row as a new entry to the database, it only submits the last game. I know I have a problem with the loop to submit, but I just can't seem to figure out how to get it. Any help is appreciated!
here is my form:
<?php require_once('Connections/t2016.php'); ?>
<?php
mysql_select_db($database_t2016, $t2016);
$query_gamedays = "SELECT DISTINCT schedule.weekDay, schedule.`date` FROM schedule WHERE schedule.weekNum=1";
$gamedays = mysql_query($query_gamedays, $t2016) or die(mysql_error());
$row_gamedays = mysql_fetch_assoc($gamedays);
$totalRows_gamedays = mysql_num_rows($gamedays);
?>
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Untitled Document</title>
</head>
<body>
<form action="" method="post" name="form1">
<table border="2" cellpadding="3" cellspacing="2">
<tr align="center">
<td>Time</td>
<td colspan="3">Matchup</td>
<td>Current Pick</td>
</tr>
<?php do {
$day = $row_gamedays['weekDay'];
$date = $row_gamedays['date'];
?>
<tr wrap="nowrap">
<td colspan="5"><?php echo '<strong>'.$day.'</strong>, '.$date; ?></td>
</tr>
<?php
mysql_select_db($database_t2016, $t2016);
$query_sched = "SELECT * FROM schedule WHERE schedule.weekNum=1 AND schedule.weekDay='$day'";
$sched = mysql_query($query_sched, $t2016) or die(mysql_error());
$row_sched = mysql_fetch_assoc($sched);
$totalRows_sched = mysql_num_rows($sched);
?>
<?php do {
$gameid = $row_sched['gameID'];
$time = $row_sched['time'];
$vteam = $row_sched['visitorID'];
$hteam = $row_sched['homeID'];
mysql_select_db($database_t2016, $t2016);
$query_picks = "SELECT * FROM picks WHERE picks.gameID=$gameid AND picks.userID=1";
$picks = mysql_query($query_picks, $t2016) or die(mysql_error());
$row_picks = mysql_fetch_assoc($picks);
$totalRows_picks = mysql_num_rows($picks);
if($totalRows_picks > 0) {
$pick = $row_picks['pickID'];
$tbp = $row_picks['tiebreakerPoints'];
} else {
$pick = 'No Pick';
$tbp = '0';
}
$vp = '';
$hp = '';
if($pick == $vteam) {
$vp = 'checked';
} elseif($pick == $hteam) {
$hp = 'checked';
}
?>
<tr align="center">
<td><?php echo $time; ?></td>
<td align="right"><?php echo $vteam.'<input type="radio" name="pickID'.$gameid.'[]" value="'.$vteam.'" '.$vp.'>'; ?></td>
<td align="center"> # </td>
<td align="left"><?php echo '<input type="radio" name="pickID'.$gameid.'[]" value="'.$hteam.'" '.$hp.'>'.$hteam; ?></td>
<td><?php echo $pick; ?></td>
</tr>
<?php if($row_sched['is_tiebreaker'] > 0) { ?>
<tr>
<td colspan="4" align="right" wrap="nowrap"><?php echo 'Enter Tiebreaker Points: <input type="number" name="tbpoints[]" min="0" value="'.$tbp.'">'; ?></td>
<td align="center"><?php echo $tbp; ?></td>
</tr>
<?php } ?>
<input type="hidden" name="gameID[]" value="$gameid">
<input type="hidden" name="userID" value="1">
<?php } while ($row_sched = mysql_fetch_assoc($sched)); ?>
<tr>
<?php } while ($row_gamedays = mysql_fetch_assoc($gamedays)); ?>
<td colspan="5" align="right" wrap="nowrap">
<input type="submit" name"submit" value="Submit Picks">
</td>
</tr>
</table>
</form>
<p> </p>
</body>
</html>
<?php
mysql_free_result($sched);
mysql_free_result($picks);
mysql_free_result($gamedays);
?>
again, the form is really rough so please be kind. Thanks for the help
You just loop through these values like a normal array.
$gameID = $_POST['gameID'];
for($x=0; $x<count($gameID); $x++ ) { .... }
As for the radio buttons/check boxes - you need to give each group a unique name. The only thing to remember with these controls is that if that are not set then nothing is submitted to the server. You need to check if they are part of the post values i.e.
if( isset( $_POST['cbPoints'] ) ) { do something }
Otherwise you'll get errors when trying to access them.
Related
I'm creating a table that uses PHP to pull from a MySQL database that I have. I think I've got everything where I want it to be, however the only problem I'm having is that the results seem to be (for lack of a better word) "behind". What I mean by that is that my first page index.php is where I'm accepting user edits to the database. Once they click Update it sends them to my results.php file that is supposed to actually perform the SQL UPDATE and then display the updated table.
It updates the table just fine according to XAMPP's database editor. However, when I said "behind" I mean that the page loads, updates but doesn't display the updated data until either the user refreshes the page or returns to the first page THEN comes back. I'm not sure what could be causing it, so I'm hoping someone here can help me. I feel like the reason is something as simple as I'm just running the code in the wrong order, but I don't know for sure. My code is below:
index.php
<html>
<body>
<?php
include('dbconnect.php');
$query = "SELECT * FROM vw_events";
$result = mysqli_query($conn, $query);
$count = mysqli_num_rows($result);
?>
<form name="form1" method="post" action="results.php">
<table width="auto" border="1" cellspacing="1" cellpadding="5">
<tr>
<td align="center"><strong>Event ID</strong></td>
<td align="center"><strong>Title</strong></td>
<td align="center"><strong>Topic</strong></td>
<td align="center"><strong>Description</strong></td>
<td align="center"><strong>Event Date</strong></td>
<td align="center"><strong>Speaker</strong></td>
<td align="center"><strong>Building</strong></td>
<td align="center"><strong>Room</strong></td>
</tr>
<?php
while($rows=mysqli_fetch_array($result)) {
?>
<tr>
<input name="event_id[]" type="hidden" id="event_id" value="<?php echo $rows['event_id']; ?>">
<td align="center">
<?php echo $rows['event_id'];?>
</td>
<td align="center">
<input name="title[]" type="text" id="title">
</td>
<td align="center">
<?php echo $rows['topic_name']; ?>
</td>
<td align="center">
<?php echo $rows['topic_description']; ?>
</td>
<td align="center">
<input name="date[]" type="date" id="date">
</td>
<td align="center">
<input title="Use reference tables below to enter speaker ID" name="speaker[]" type="text" id="speaker">
</td>
<td align="center">
<input title="Use reference tables below to enter building ID" name="building[]" type="text" id="building">
</td>
<td align="center">
<input title="Use reference tables below to enter Room ID" name="room[]" type="text" id="room">
</td>
</tr>
<?php
}
?>
<tr>
<td colspan="8" align="center"><input type="submit" name="Update" value="UPDATE"></td>
</tr>
</table>
</form>
</body>
</html>
results.php
<html>
<body>
<?php
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
error_reporting(E_ALL);
ini_set('display_errors',1);
require_once('dbconnect.php');
$query = "SELECT * FROM vw_events";
$result = mysqli_query($conn, $query);
$count = mysqli_num_rows($result);
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
$id = $_POST['event_id'];
$title2 = $_POST['title'];
$date2 = $_POST['date'];
$speaker2 = $_POST['speaker'];
$building2 = $_POST['building'];
$room2 = $_POST['room'];
for($i=0;$i<$count;$i++) {
$sql="UPDATE events SET title='$title2[$i]', event_date='$date2[$i]', speaker='$speaker2[$i]', building='$building2[$i]', room='$room2[$i]' WHERE event_id='$id[$i]'";
$result1=mysqli_query($conn, $sql);
}
}
?>
<form name="form1" method="post" action="index.php">
<table width="auto" border="1" cellspacing="1" cellpadding="5">
<tr>
<td align="center"><strong>Event ID</strong></td>
<td align="center"><strong>Title</strong></td>
<td align="center"><strong>Topic</strong></td>
<td align="center"><strong>Description</strong></td>
<td align="center"><strong>Event Date</strong></td>
<td align="center"><strong>Speaker</strong></td>
<td align="center"><strong>Building</strong></td>
<td align="center"><strong>Room</strong></td>
</tr>
<?php
while($rows=mysqli_fetch_array($result)) {
?>
<tr>
<td align="center">
<?php echo $rows['event_id'];?>
</td>
<td align="center">
<?php echo $rows['title']; ?>
</td>
<td align="center">
<?php echo $rows['topic_name']; ?>
</td>
<td align="center">
<?php echo $rows['topic_description']; ?>
</td>
<td align="center">
<?php echo $rows['event_date']; ?>
</td>
<td align="center">
<?php echo $rows['speaker_name']; ?>
</td>
<td align="center">
<?php echo $rows['building_name']; ?>
</td>
<td align="center">
<?php echo $rows['room_name']; ?>
</td>
</tr>
<?php
}
?>
<tr>
<td colspan="8" align="center"><input type="submit" name="Return" value="Return"></td>
</tr>
</table>
</form>
</body>
</html>
Also if someone can give me some guidance as to how to run the htmlspecialchars function on my arrays within results.php I'd really appreciate it. I've already tried to create a for loop for literally each array but that didn't work. I've tried using ->
<?php
function htmlspecial_array(&$variable) {
foreach ($variable as &$value) {
if (!is_array($value)) { $value = htmlspecialchars($value); }
else { htmlspecial_array($value); }
}
}
but that also didn't work, and I've tried using the array_walk_recursive but to no avail. I want to try and do something like W3Schools' example here W3Schools Form Validation towards the bottom of the page where it says Validate Form Data With PHP and then gives an example.
The result you get from the UPDATE query is the number of affected rows in your database. To correctly display the updated data, you need to re-fetch from the database before you generate the HTML. You should rearrange your code in results.php like this:
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
error_reporting(E_ALL);
ini_set('display_errors',1);
require_once('dbconnect.php');
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
$id = $_POST['event_id'];
$title2 = $_POST['title'];
$date2 = $_POST['date'];
$speaker2 = $_POST['speaker'];
$building2 = $_POST['building'];
$room2 = $_POST['room'];
$query = "SELECT * FROM vw_events";
$result = mysqli_query($conn, $query);
$count = mysqli_num_rows($result);
for($i=0;$i<$count;$i++) {
$sql="UPDATE events SET title='$title2[$i]', event_date='$date2[$i]', speaker='$speaker2[$i]', building='$building2[$i]', room='$room2[$i]' WHERE event_id='$id[$i]'";
$result1=mysqli_query($conn, $sql);
}
}
$query = "SELECT * FROM vw_events";
$result = mysqli_query($conn, $query);
Side note: If your data is sensitive, you may want to read about mysqli prepared statement so hackers cannot tamper with your queries.
Regarding your question about htmlspecialchars, see Stackoverflow "Execute htmlspecialchars on a multi level array".
Good morning,
I was searching, but couldn't find answer :(
I have a table created dynamically with data taken from MSSQL:
$tabelka = '
<form action="index.php" method="post">
<table border =1 width=40% class="hoverTable"><tr>
<td width=10%><B>Biuro</B></td>
<td width=10%><b>Drukarka</b></td>
<td width=20%><b>Toner</b></td>
<td width=10%><b>Na stanie</b></td>
<td width=10%><b>Zamówionych</b></td>
<td width=10%><b>Akcja</b></td></tr>';
$sql = 'select * from raportTonerow';
if ($result = sqlsrv_query($conn, $sql)) {
while ($row = sqlsrv_fetch_array($result)) {
$tabelka .= '
<tr><td width=10%>'.$row['kodBiura'].'</td>
<td width=10%>'.$row['nazwaDrukarki'].'</td>
<td width=20%>'.$row['toner'].'</td>
<td width=10%>
<input type="number" name="naStanie" size=10% maxlength=1 value="'.$row['naStanie'].'"></td>
<td width=10%><input type="number" name="zamowionych" size=10% maxlength=1 value="'.$row['zamowionych'].'"></td>
<td width=10%><input type="submit" value="Aktualizuj" name="akt"></td>';
}
}
$tabelka .= '</form></table>';
and
if (isset($_POST['akt'])) {
echo "test ".$_POST['zamowionych'];
}
it is showing me only last data from table. How can I pass variables from each row?
What I want to have is: when user click on button on the row only data from that row will be send in form.
thank you
Lukasz
<?php
while($row=mysql_fetch_array($sql))
{
?>
<td> <?php echo $row->kodBiura;?></td>
<td> <?php echo $row->nazwaDrukarki; ?></td>
<td> <?php echo $row->toner; ?></td>
<?php }?>
<?php
session_start();
include("configdb.php");
if(!session_is_registered(username)){
header("location:index.php");
}
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Projects</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
function un_check(){
for (var i = 0; i < document.frmactive.elements.length; i++) {
var e = document.frmactive.elements[i];
if ((e.name != 'allbox') && (e.type == 'checkbox')) {
e.checked = document.frmactive.allbox.checked;
}
}
}
function Confirm(form){
alert("Project has been activated!");
form.submit();
}
function unConfirm(form){
alert("Project has been Deactivated!");
form.submit();
}
</script>
</head>
<body>
<div id="costDiv">
<div id="divErc"></div>
<div id="costBack">
<?php
if(isset($_POST['checkbox'])){$checkbox = $_POST['checkbox'];
if(isset($_POST['activate'])?$activate = $_POST["activate"]:$deactivate = $_POST["deactivate"])
$id = "('" . implode( "','", $checkbox ) . "');" ;
$sql="UPDATE projects SET p_isActive = '".(isset($activate)?'1':'0')."' WHERE p_id IN $id";
$result = mysql_query($sql) or die(mysql_error());
}
?>
<?php include("hor_menu.php"); ?>
<form name="frmactive" method="post" action="">
<table width="350" border="0" cellspacing="1" cellpadding="5" align="center" style="margin-left:150px ; margin-right:auto ; margin-top:20px ; margin-bottom:auto ; position:absolute ; width:400px">
<tr>
<td align="center" ><input type="checkbox" name="allbox" onclick="un_check(this);" title="Select or Deselct ALL" style="background-color:#ccc;"/></td>
<td align="left"><strong>Project</strong></td>
<td align="left"><strong>Country</strong></td>
<td align="left"><strong>Active</strong></td>
</tr>
<?php
while($rows=mysql_fetch_array($result)){
?>
<tr>
<td align="center"><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<?php echo $rows['p_id']; ?>"/></td>
<td><?php echo $rows['p_name']; ?></td>
<td><?php echo $rows['p_country']; ?></td>
<td><?php if ($rows['p_isActive'] == '1'){ echo'Active';} else{ echo 'Inactive';} ?></td>
</tr>
<?php
}
?>
<tr>
<td colspan="5"><input name="activate" type="submit" id="activate" value="Activate" onClick="Confirm(this.form)" />
<input name="deactivate" type="submit" id="deactivate" value="Deactivate" onClick="unConfirm(this.form)"/></td>
</tr>
</table>
?>
</td>
</tr>
</table>
</form>
</body>
</html>
i have this code.when i check a checkbox project will be either activated or deactivated according to bottom.however this code works perfectly on all browsers except google chrome and safari.can anyone help please.it keeps giving that have an error in my sql syntax espeaciall after the where clause in the update query.thank you
If you get an SQL error depending on browser, then you most likely need to check your inputs. PHP execution does not differ depending on what browser you're using, other than what data it gets from client side controls like textboxes or triggers.
I suggest you log the $sql variable in some way, you could try just using var_dump, to see how the data changes between browsers.
This is not legal: id="checkbox[]" get rid of it.
It's not necessary to assign everything an ID. Only assign an ID if you actually use it in the javascript. Otherwise just leave it out.
INPUT fields do need a name attribute, but that works completely differently from an ID.
Rather noobish question but I have tried searching and just cannot find a solution. My problem is I have a table called Off, which stores all of the staffs holidays. However before a staff member may have that day off it has to be authorised. I have a query which gets all of the unauthorised holidays and I display them in a html table. The problem is that I need 2 radio buttons per record. one for authorise and one for deny. The radio buttons are displayed but when going through the records only one of the radio buttons is selectable. Is it possible to use radio buttons in this way?
<?php
$path = $_SERVER['DOCUMENT_ROOT'];
$path .= "/Apollo/dbc.php";
include_once($path);
$rs_results = mysql_query("SELECT * FROM off WHERE IsItAuthorised='0' and isitsick='0' ORDER BY DayOff");
?>
<html>
<head>
<title>Administration Main Page</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<?php
$limit = count($OffID);
if (isset($_POST['submit'])) {
//Assign each array to a variable
$id = $_POST['OffID'];
$answer = $_POST['radio'];
$limit = count($OffID);
$values = array(); // initialize an empty array to hold the values
for($k=0;$k<$limit;$k++){
$msg[] = "$limit New KPI's Added";
$query = "UPDATE Off SET IsItAuthorised = '{$answer[$k]}' WHERE OffID = '{$OffID[$k]}'";
}
$Event = "INSERT INTO events (UserName, Event ) VALUES ('$_SESSION[user_name]', 'Entered New KPI' )";
if (!mysql_query($query,$link)){
die('Error: ' . mysql_error());
} else {
mysql_query($Event);
echo "<div class=\"msg\">" . $msg[0] . "</div>";
}
}
?>
</head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="14%" valign="top"><?php
?>
</td>
<td width="74%" valign="top" style="padding: 10px;">
<p><?php
if(!empty($msg)) {
echo $msg[0];
}
?></p>
<p>
<?php
$cond = '';
$sql = "select * from off ";
$rs_total = mysql_query($sql) or die(mysql_error());
$total = mysql_num_rows($rs_total);
?>
<p>
<form name "searchform" action="/Apollo/Admin/HolidayRequests" method="post">
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="0">
<tr class="mytables">
<td width="4%"><font color="white"><strong>ID</font></strong></td>
<td width="4%"> <font color="white"><strong>Staff Member</font></strong></td>
<td width="10%"><font color="white"><strong>Day Off</font></strong></div></td>
<td width="10%"><font color="white"><strong>Is It Authorized</font></strong></div></td>
<td width="15%"> </td>
</tr>
<tr>
<td> </td>
<td width="10%"> </td>
<td width="17%"><div align="center"></div></td>
<td> </td>
</tr>
<?php while ($rrows = mysql_fetch_array($rs_results)) {?>
<tr>
<td><input type="" name="id[]" id="id[]" size="4" value="<?php echo $rrows['OffID'];?>" /></td>
<td><?php echo $rrows['StaffMember']; ?></td>
<td><?php echo date('d/m/Y', strtotime($rrows['DayOff']));?></div></td>
<td> <span id="approve<?php echo $rrows['id']; ?>">
<?php if(!$rrows['IsItAuthorised']) { echo "Pending"; } else {echo "Authorized"; }?>
</span> </td>
<td>
<input type="radio" name="radio[0]" id="radio[0]" value="1" />Approve
<input type="radio" name="radio[1]" id="radio[1]" value="0" />Deny
</td>
</tr>
<?php } ?>
</table>
<input name="submit" type="submit" id="submit" value="Submit">
</form>
</p>
<?php
?>
<p> </p>
<p> </p>
<p> </p>
<p> </p></td>
<td width="12%"> </td>
</tr>
</table>
</body>
</html>
Your problem is to do with your use of the "name" attribute - this attribute is used in a special way on radio buttons.
When you click on a radio button, all the other radio buttons with the same name are deselected - in your case, you will have half of the radio buttons on the page in one group and half in another, which would probably explain why you can only select one. I'd imagine you can actually select two at the same time, if you click on the right radio buttons.
To fix this you'd need to have some kind of count for the while loop, ie:
$resultNumber = 0;
while ($rrows = mysql_fetch_array($rs_results)) {
Then you'd need to use this number in the name (and also id) of the radio buttons -
<input type="radio" name="radio<?php echo $resultNumber; ?>" id="radio<?php echo $resultNumber; ?>" value="1" />
Then simply increment the $resultNumber at the end of each iteration -
<?php
$resultNumber++;
}
?>
Alternatively, you could use the primary key of the row from the database table you're querying to distinguish groups, but not knowing the table structure I couldn't give sample code for that.
Further reading on radio buttons (also a source for the name attribute problem) :
http://www.echoecho.com/htmlforms10.htm
Instead of radio buttons, I used checkboxes, which I looped through. Each checkbox set a value to a different column. Should have been obvious to me to begin with.
hey guys im having trouble with an array. all i need is for the query to update 2 columns on the table based on the records id
The table has a column called OffID and it looks for any record that has not yet been authorised. to mark it authorised the user will select a check box for either authorise or deny and then press the submit button. however at the moment i have 9 records which show in the table each with there own unique id but when submit is selected it will only update one. any help in showing where ive gone wrong would be grateful and cheers in advance :)
ok i edited the code but it is only now setting the first record. so if there are 8 records and i choose accept for the first record and deny for the second record both the accept and deny are set to the first record in the database my new code is below
<?php
$path = $_SERVER['DOCUMENT_ROOT'];
$path .= "/Apollo/dbc.php";
include_once($path);
$rs_results = mysql_query("SELECT * FROM off WHERE IsItAuthorised='0' and isitsick='0' ORDER BY DayOff");
?>
<html>
<head>
<title>Administration Main Page</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<?php
if (isset($_POST['submit'])) {
//Assign each array to a variable
$id = $_POST['id'];
$approve = $_POST['approve'];
$deny = $_POST['deny'];
$limit = count($rs_results);
$values = array(); // initialize an empty array to hold the values
for($k=0;$k<$limit;$k++){
$msg[] = "$limit New KPI's Added";
$query = "UPDATE off SET Authorised = '$approve[$k]', Deny = '$deny[$k]' WHERE OffID = '$id[$k]'";
}
$Event = "INSERT INTO events (UserName, Event ) VALUES ('$_SESSION[user_name]', 'Entered New KPI' )";
echo $query;
if (!mysql_query($query,$link)){
die('Error: ' . mysql_error());
} else {
mysql_query($Event);
echo "<div class=\"msg\">" . $msg[0] . "</div>";
}
}
?>
</head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="14%" valign="top"><?php
?>
</td>
<td width="74%" valign="top" style="padding: 10px;">
<p><?php
if(!empty($msg)) {
echo $msg[0];
}
?></p>
<p>
<?php
$cond = '';
$sql = "select * from off ";
$rs_total = mysql_query($sql) or die(mysql_error());
$total = mysql_num_rows($rs_total);
?>
<p>
<form name "searchform" action="/Apollo/Admin/HolidayRequests.php" method="post">
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="0">
<tr class="mytables">
<td width="4%"><font color="white"><strong>ID</font></strong></td>
<td width="4%"> <font color="white"><strong>Staff Member</font></strong></td>
<td width="10%"><font color="white"><strong>Day Off</font></strong></div></td>
<td width="10%"><font color="white"><strong>Is It Authorized</font></strong></div></td>
<td width="15%"> </td>
</tr>
<tr>
<td> </td>
<td width="10%"> </td>
<td width="17%"><div align="center"></div></td>
<td> </td>
</tr>
<?php while ($rrows = mysql_fetch_array($rs_results)) {?>
<tr>
<td><input name="id[]" id="id[]" size="4" value="<?php echo $rrows['OffID'];?>" /></td>
<td><?php echo $rrows['StaffMember']; ?></td>
<td><?php echo date('d/m/Y', strtotime($rrows['DayOff']));?></div></td>
<td> <span id="approve<?php echo $rrows['id']; ?>">
<?php if(!$rrows['IsItAuthorised']) { echo "Pending"; } else {echo "Authorized"; }?>
</span> </td>
<td>
<input type="checkbox" name="approve[]" id="approve[]" value="1"> Approve
<input type="checkbox" name="deny[]" id="deny[]" value="1"> Deny
</td>
</tr>
<?php } ?>
</table>
<input name="submit" type="submit" id="submit" value="Submit">
</form>
</p>
<?php
?>
<p> </p>
<p> </p>
<p> </p>
<p> </p></td>
<td width="12%"> </td>
</tr>
</table>
</body>
</html>
isn't it because your $id etc isn't passes an array:
$id = $_POST['id'];
$approve = $_POST['approve'];
$deny = $_POST['deny'];
You're using $_POST['id'] but nowhere in your <form/> do I see any <input name="id[]"/> which could provide the data