RE: [PHP-DB] How to pass multiple checkbox values thru form??

2002-08-31 Thread victor

I'm working on the same problem but I need to read the code, not write
it:, here are a few links and my code if you might help me in return:

http://www.experts-exchange.com/Web/Web_Languages/PHP/Q_20117420.html

my code:

mysql_db(); # connects to mysql

for($i = 0; $i  sizeof($check); $i++) {
# echo $i;
# echo 'p';
# $data = $check[$i];
$sql = (SELECT * FROM kodak_user_pictures WHERE ID = '$check[$i]');
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
# $row = mysql_fetch_array($db_data);
$db_ID = $row[ID];
$db_picture_name = $row[picture_name];
echo $db_ID;
echo 'p';
echo $db_picture_name;
echo 'p';
echo $ID;
echo 'p';
echo $picture_name;
echo 'p';
echo $result;
}

so many echoes because I'm trying to figure out what works and what
doesn't.

- Victor  www.argilent.com

-Original Message-
From: Smita Manohar [mailto:[EMAIL PROTECTED]] 
Sent: Friday, August 30, 2002 12:19 AM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] How to pass multiple checkbox values thru form??

hii
i have one form in which i print records from mysql database. while 
displyaing those records i display one checkbox with each record. i want
the 
user should select the checkbox corresponding to the record which s/he
wants 
to delete.

i display those records after running one query. hence each time no.of 
records are diff. so its difficult to hard code names for check boxes.
for 
name attribute in input type=checkbox tag, i define one array. having
same 
name as the key field in the table. and value for which is also set 
dynamically.

FORM NAME = act_qmd_subj_frm METHOD = POST ACTION = 
confirm_delete.php

while ($row = mysql_fetch_array($result))
 {

..
 echo tr;

   //call function to display the contents of $row in table
print_entry($row,subj_id,subj_name,subj_desc);


print   td valign=top align=centerinput type=checkbox  
name=\subj_id[]\ value=\.$row[subj_id].\ Yes, delete entry 
#.$row[subj_id]./td\n;

  ...

 }

 INPUT TYPE=submit NAME=del_but VALUE=Delete nbsp nbsp
 INPUT TYPE=submit NAME=modify_but VALUE=Modify nbsp nbsp
 INPUT TYPE=reset NAME=clear_but VALUE=Clear nbsp nbsp

/FORM

when i submit the form to confirm_delete.php i run one code there to
print 
the array subj_id[]  which is supposed to contain values of the
checkboxes 
which are selected to delete or to modify. but the array subj_id[]
contains 
no value at all. echo count($subj_id) gives 0.

is there any other way to pass multiple checkbox values from the form???

i got the above trick from the book MySQL/PHP Database Applications
(By, 
Jay Grrenspan and Brad Bulger) in one script they have passed checkbox
value 
thru array by this way, and its working fine.

can anyone PLS figure out what wrong im doing???

thnx and regds,
smita.



_
MSN Photos is the easiest way to share and print your photos: 
http://photos.msn.com/support/worldwide.aspx


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

__ 
Post your ad for free now! http://personals.yahoo.ca

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP-DB] How to pass multiple checkbox values thru form??

2002-08-29 Thread Russ

Smita:

input type='checkbox' name='YourFieldName[]' value=\$DataBaseValue\
/

Then in the script that recieves the form POST or GET data, cycle
through the array of chaeckbox values and do with them as you will.

foreach($YourFieldName as $val)
{
//echo checkbox values to the page or do whatver you will with
them..  
echo checkbox value: $val;
}

:-)

HTH
Russ

-Original Message-
From: Smita Manohar [mailto:[EMAIL PROTECTED]]
Sent: Friday, August 30, 2002 12:19 PM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] How to pass multiple checkbox values thru form??


hii
i have one form in which i print records from mysql database. while 
displyaing those records i display one checkbox with each record. i want
the 
user should select the checkbox corresponding to the record which s/he
wants 
to delete.

i display those records after running one query. hence each time no.of 
records are diff. so its difficult to hard code names for check boxes.
for 
name attribute in input type=checkbox tag, i define one array. having
same 
name as the key field in the table. and value for which is also set 
dynamically.

FORM NAME = act_qmd_subj_frm METHOD = POST ACTION = 
confirm_delete.php

while ($row = mysql_fetch_array($result))
 {

..
 echo tr;

   //call function to display the contents of $row in table
print_entry($row,subj_id,subj_name,subj_desc);


print   td valign=top align=centerinput type=checkbox  
name=\subj_id[]\ value=\.$row[subj_id].\ Yes, delete entry 
#.$row[subj_id]./td\n;

  ...

 }

 INPUT TYPE=submit NAME=del_but VALUE=Delete nbsp nbsp
 INPUT TYPE=submit NAME=modify_but VALUE=Modify nbsp nbsp
 INPUT TYPE=reset NAME=clear_but VALUE=Clear nbsp nbsp

/FORM

when i submit the form to confirm_delete.php i run one code there to
print 
the array subj_id[]  which is supposed to contain values of the
checkboxes 
which are selected to delete or to modify. but the array subj_id[]
contains 
no value at all. echo count($subj_id) gives 0.

is there any other way to pass multiple checkbox values from the form???

i got the above trick from the book MySQL/PHP Database Applications
(By, 
Jay Grrenspan and Brad Bulger) in one script they have passed checkbox
value 
thru array by this way, and its working fine.

can anyone PLS figure out what wrong im doing???

thnx and regds,
smita.



_
MSN Photos is the easiest way to share and print your photos: 
http://photos.msn.com/support/worldwide.aspx


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php