Page 3 of 3
Posted: Wed Aug 18, 2004 9:56 pm
by feyd
I'm not sure which field you need to update so they move into the approved status.. so uh...
well.. it should only need some changes to the 'foo' line..
Posted: Wed Aug 18, 2004 10:02 pm
by g3ckO
I need to update the field status from table leave.
So when the user clicked the Approved button.. the value of status will change from Pending Review to Approved.
When the user clicked the Not Approved button.. the value of status will change from Pending Review to Not Approved.
Posted: Wed Aug 18, 2004 10:12 pm
by feyd
k.. so then it'd be something like:
Code: Select all
<?
session_start();
include("database.php");
global $conn;
$statusby = $_POST['statusby'];
if(isset($_POST['app']))
{
$sql = 'UPDATE leave SET ';
$sql .= 'status = ''Approved'' ';
$sql .= 'WHERE RefID IN(''' . implode(''',''', $_POST['approved']) . ''')';
mysql_query($query, $conn);
}
elseif(isset($_POST['notapp']))
{ // not approved clicked..
$sql = 'UPDATE leave SET ';
$sql .= 'status = ''Not Approved'' ';
$sql .= 'WHERE RefID IN(''' . implode(''',''', $_POST['approved']) . ''')';
mysql_query($query, $conn);}
else
{ // in case someone hits enter for the submittal...
die('YOU MUST SELECT EITHER <b>APPROVED</b> OR <b>NOT APPROVED</b>.');
}
?>
Posted: Wed Aug 18, 2004 10:38 pm
by g3ckO
When I don't checked any checkbox and clicked the approved button I got this error:
Warning: implode(): Bad arguments. in c:\apache\htdocs\leave_app_2.php on line 15
But when I checked the checkbox, I don't get any error message but the status in database still not change.
Posted: Wed Aug 18, 2004 10:53 pm
by feyd
I warned you that you'll need to add some checks for an empty set of checkboxes...
As for it not updating, it may have an error in the syntax (depending on the RefID being right or not) adding "or die(mysql_error())" to each mysql_query call would tell you if there's a syntax error..
Posted: Wed Aug 18, 2004 11:04 pm
by g3ckO
feyd wrote:I warned you that you'll need to add some checks for an empty set of checkboxes...

I will do the check later..
The data not updating coz it say the Query was empty. But why??
Posted: Wed Aug 18, 2004 11:11 pm
by feyd
switch $query for $sql
Posted: Wed Aug 18, 2004 11:19 pm
by g3ckO
Okay².... its work now..
Thank you very² much
feyd...
~feyd.. the real guru..

Posted: Wed Aug 18, 2004 11:40 pm
by g3ckO
one more question.. simple one I think..
Code: Select all
<?php
$sql .= 'Status = ''Approved'' ,StatusBy = ''$statusby'' ';
?>
It update
Statusby field to $statusby in database, not the value of $statusby.
I want the value of $statusby to be update to database.
Posted: Wed Aug 18, 2004 11:59 pm
by feyd
Code: Select all
$sql .= 'Status = ''Approved'' ,StatusBy = ''' . $statusby . ''' ';
Posted: Thu Aug 19, 2004 1:25 am
by g3ckO
Problem solved..