When the user press any of the button,I want the row of data to be updated but don't know how it will be done can any one help me please??
The code is..
Code: Select all
<head>
<body>
<?php
session_start();
$d= $_SESSION['txt_id'];
include ('dbinfo.inc');
echo mysql_error();
$query=mysql_query("SELECT * FROM `login` WHERE `login_id` LIKE '$d'");
if(mysql_num_rows($query) >0){
while($far=mysql_fetch_array($query)){
$level=$far[4];
$dept=$far[3];}
}
$result = mysql_query("SELECT * FROM `request` WHERE `req_for_dept` LIKE '$dept' AND `status` LIKE 'basic'");
echo " <h1><strong><center>Request/s</center></strong></h1>";
///****************** Print out lthe contents of each row into a table *************************///
echo "<body bgcolor='#cfad5f'><table width='90%' border='1' align='center' cellpadding='5' cellspacing='1' bgcolor='' class='text_brown' >";
echo " <tr align='center' >";
echo " <td ><h3>Request no</h3></td>";
echo " <td><h3>Item name</h3></td>";
echo " <td><h3>Request for Department</h3></td>";
echo " <td><h3>Quantity</h3></td>";
echo " <td><h3>Request Date</h3></td>";
echo " <td><h3>Status</h3></td>";
echo " <td><h3>Action</h3></td>";
$field = mysql_fetch_field($result);
if($fields_num = mysql_num_fields($result)){
for($i=0; $i<$fields_num; $i++){
while($val=mysql_fetch_array($result))
{
echo "<tr class=\"black\">";
echo " <td align='center' width='15%'>".$val[0]."</td> ";
echo " <td align='center' width='20%'>".$val[4]."</td> ";
echo " <td align='center' width='25%'>".$val[2]."</td> ";
echo " <td align='center' width='25%'>".$val[6]."</td> ";
echo " <td align='center' width='20%'>".$val[8]."</td> ";
echo " <td align='center' width='20%'>".$val[10]."</td> ";
echo "<td 'align='center' width='80%'>".('<form action="action.php?req_no=<?$val[req_no]?>" method="post">
<div align="center"> <input name="submit" type="submit" value="Accept Request" />
<input name="submit" type="submit" value="Reject Request" />
<input name="hiddenValue" type="hidden" value="$val[0]"/>')."</td>";
echo "</tr>";
}}
echo"</table>";}
else
echo " <body bgcolor='#cfad5f'><h2><strong><center>No Request Found</center></strong></h2>";
?>
</body>
</html><?php
session_start();
$d= $_SESSION['txt_id'];
include ('dbinfo.inc');
if (isset($_POST['Yes'])){
$sql =mysql_query("UPDATE TABLE `request` SET `status` = 'approved' WHERE 'req_no'='$_POST['req_no']");
//$result= mysql_query("UPDATE 'request' SET 'status' LIKE 'approved' WHERE 'req_no'= ''");
$_SESSION['txt_id'] = $_POST['txt_id'];
header ('Location:success.php');
}
else if (isset($_POST['No'])){
$_SESSION['txt_id'] = $_POST['txt_id'];
header ('Location:req_display.php');
}
?>
Please help I am stuck..