Page 2 of 3
Posted: Tue Aug 17, 2004 11:44 pm
by g3ckO
feyd wrote:$row['RefID'] probably isn't set... need to pull it from the posted data... should be inside $_POST['approved']
print_r($_POST['approved']) to look at the data
The form "
leave_app.php" is like the 1st one I post on this topic and the "
leave_app_2" is the last one.
How should I know whether
$row['RefID'] is set or not?
Sorry for bothering you again and again...
Posted: Tue Aug 17, 2004 11:54 pm
by feyd
print_r($_POST) to look at the data posted.... figure out if it's in there...
Posted: Wed Aug 18, 2004 12:55 am
by g3ckO
Array ( [approved] => Array ( [0] => L(TAB01281)(2004-03-07) [1] => L(TAB00981)(2004-03-12) ) [statusby] => Abd. Malek B. Aziz [app] => APPROVED )
what its mean??
Posted: Wed Aug 18, 2004 12:58 am
by feyd
that means $_POST['approved'] is an array of your RefID's to approve.. it looks like...
Posted: Wed Aug 18, 2004 1:09 am
by g3ckO
so.. how should I do.. the database do not update when I clicked the APPROVED button

Posted: Wed Aug 18, 2004 1:10 am
by feyd
create updates to mark all the 'approved' ones as such..
[edit: using loops of some nature or another]
Posted: Wed Aug 18, 2004 1:13 am
by g3ckO
feyd wrote:create updates to mark all the 'approved' ones as such..
can you show or explain it a little bit...
Posted: Wed Aug 18, 2004 1:18 am
by feyd
Code: Select all
UPDATE tablename SET foo = 'hi', bar = 2 WHERE RefID IN('L(TAB01281)(2004-03-07)','L(TAB00981)(2004-03-12)')
Code: Select all
$sql = 'UPDATE tablename SET ';
$sql .= 'foo = ''hi'' '; // some field name change value..
$sql .= 'WHERE RefID IN(''' . implode(''',''', $_POST['approved']) . ''')';
that needs to be done only if approved isn't empty, of course..
Posted: Wed Aug 18, 2004 4:14 am
by g3ckO
2 days... still cannot complete this...
Hmm.. any suggestion for more simpler way that easy to understand??
Posted: Wed Aug 18, 2004 4:50 pm
by tim
sorry for the confusion, I thought the RefID was the way you should target specific rows
feyd is correct (as always)
Posted: Wed Aug 18, 2004 8:25 pm
by g3ckO
-feyd..
any code snippets can you show me regarding this topic.
Posted: Wed Aug 18, 2004 8:29 pm
by feyd
did you try something like my last post?
Posted: Wed Aug 18, 2004 8:56 pm
by g3ckO
I don't understand it.
'foo, implode... never use it before..
don't know which part should I change from my code..
More and more confuse..
Posted: Wed Aug 18, 2004 8:58 pm
by feyd
the foo line is the one to change to the fieldnames and values you need to change in each of the id's...
Posted: Wed Aug 18, 2004 9:12 pm
by g3ckO
can you show me a skeleton how should I write my leave_app2.php.
What should I change from it:
Code: Select all
<?php
<?
session_start();
include("database.php");
global $conn;
$statusby = $_POST['statusby'];
if ($_POST['app'])
{
$sql = 'UPDATE leave SET ';
$sql .= 'foo = ''hi'' ';
$sql .= 'WHERE RefID IN(''' . implode(''',''', $_POST['approved']) . ''')';
mysql_query($query, $conn);
}
?>