[SOLVED] checkbox value

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

User avatar
g3ckO
Forum Contributor
Posts: 117
Joined: Mon Jul 12, 2004 2:57 am
Location: Malaysia
Contact:

Post 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...
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

print_r($_POST) to look at the data posted.... figure out if it's in there...
User avatar
g3ckO
Forum Contributor
Posts: 117
Joined: Mon Jul 12, 2004 2:57 am
Location: Malaysia
Contact:

Post 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??
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

that means $_POST['approved'] is an array of your RefID's to approve.. it looks like...
User avatar
g3ckO
Forum Contributor
Posts: 117
Joined: Mon Jul 12, 2004 2:57 am
Location: Malaysia
Contact:

Post by g3ckO »

so.. how should I do.. the database do not update when I clicked the APPROVED button :(
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

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.
User avatar
g3ckO
Forum Contributor
Posts: 117
Joined: Mon Jul 12, 2004 2:57 am
Location: Malaysia
Contact:

Post by g3ckO »

feyd wrote:create updates to mark all the 'approved' ones as such..
can you show or explain it a little bit...
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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..
User avatar
g3ckO
Forum Contributor
Posts: 117
Joined: Mon Jul 12, 2004 2:57 am
Location: Malaysia
Contact:

Post by g3ckO »

2 days... still cannot complete this... :?
Hmm.. any suggestion for more simpler way that easy to understand??
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

sorry for the confusion, I thought the RefID was the way you should target specific rows

feyd is correct (as always)
User avatar
g3ckO
Forum Contributor
Posts: 117
Joined: Mon Jul 12, 2004 2:57 am
Location: Malaysia
Contact:

Post by g3ckO »

-feyd..

any code snippets can you show me regarding this topic.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

did you try something like my last post?
User avatar
g3ckO
Forum Contributor
Posts: 117
Joined: Mon Jul 12, 2004 2:57 am
Location: Malaysia
Contact:

Post 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..
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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...
User avatar
g3ckO
Forum Contributor
Posts: 117
Joined: Mon Jul 12, 2004 2:57 am
Location: Malaysia
Contact:

Post 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);
   }
?>
Post Reply