PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
g3ckO
Forum Contributor
Posts: 117 Joined: Mon Jul 12, 2004 2:57 am
Location: Malaysia
Contact:
Post
by g3ckO » Tue Aug 17, 2004 11:44 pm
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...
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Tue Aug 17, 2004 11:54 pm
print_r($_POST) to look at the data posted.... figure out if it's in there...
g3ckO
Forum Contributor
Posts: 117 Joined: Mon Jul 12, 2004 2:57 am
Location: Malaysia
Contact:
Post
by g3ckO » Wed Aug 18, 2004 12:55 am
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??
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Wed Aug 18, 2004 12:58 am
that means $_POST['approved'] is an array of your RefID's to approve.. it looks like...
g3ckO
Forum Contributor
Posts: 117 Joined: Mon Jul 12, 2004 2:57 am
Location: Malaysia
Contact:
Post
by g3ckO » Wed Aug 18, 2004 1:09 am
so.. how should I do.. the database do not update when I clicked the APPROVED button
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Wed Aug 18, 2004 1:10 am
create updates to mark all the 'approved' ones as such..
[edit: using loops of some nature or another]
Last edited by
feyd on Wed Aug 18, 2004 1:13 am, edited 1 time in total.
g3ckO
Forum Contributor
Posts: 117 Joined: Mon Jul 12, 2004 2:57 am
Location: Malaysia
Contact:
Post
by g3ckO » Wed Aug 18, 2004 1:13 am
feyd wrote: create updates to mark all the 'approved' ones as such..
can you show or explain it a little bit...
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Wed Aug 18, 2004 1:18 am
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..
g3ckO
Forum Contributor
Posts: 117 Joined: Mon Jul 12, 2004 2:57 am
Location: Malaysia
Contact:
Post
by g3ckO » Wed Aug 18, 2004 4:14 am
2 days... still cannot complete this...
Hmm.. any suggestion for more simpler way that easy to understand??
tim
DevNet Resident
Posts: 1165 Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio
Post
by tim » Wed Aug 18, 2004 4:50 pm
sorry for the confusion, I thought the RefID was the way you should target specific rows
feyd is correct (as always)
g3ckO
Forum Contributor
Posts: 117 Joined: Mon Jul 12, 2004 2:57 am
Location: Malaysia
Contact:
Post
by g3ckO » Wed Aug 18, 2004 8:25 pm
-feyd..
any code snippets can you show me regarding this topic.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Wed Aug 18, 2004 8:29 pm
did you try something like my last post?
g3ckO
Forum Contributor
Posts: 117 Joined: Mon Jul 12, 2004 2:57 am
Location: Malaysia
Contact:
Post
by g3ckO » Wed Aug 18, 2004 8:56 pm
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..
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Wed Aug 18, 2004 8:58 pm
the foo line is the one to change to the fieldnames and values you need to change in each of the id's...
g3ckO
Forum Contributor
Posts: 117 Joined: Mon Jul 12, 2004 2:57 am
Location: Malaysia
Contact:
Post
by g3ckO » Wed Aug 18, 2004 9:12 pm
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);
}
?>