RE: [PHP-DB] Check Boxes/UPDATE
-Original Message- From: Jason G. [mailto:[EMAIL PROTECTED]] Sent: 03 October 2001 12:12 To: Matt C; [EMAIL PROTECTED] Subject: Re: [PHP-DB] Check Boxes/UPDATE Matt, Assuming that you have a variable number of records being displayed out of the database: As you write out the HTML, give each checkbox a name containing the ID# of the record that is being written out. Ex: input type=check name=chkAuthStatus_1203 checked input type=check name=chkAuthStatus_1204 checked input type=check name=chkAuthStatus_1205 checked Note that you can use arrays when naming your form elements -- isn't PHP wonderful :). Thus you can have: input type=check name=chkAuthStatus[0] checked input type=check name=chkAuthStatus[1] checked input type=check name=chkAuthStatus[2] checked ...etc This simplifies the code somewhat as you can now loop through the elements of the array $chkAuthStatus to find out whether it is checked or not. regards -- Jason Wong Gremlins Associates www.gremlins.com.hk Tel: +852-2573-5033 Fax: +852-2573-5851 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] Check Boxes/UPDATE
I am sorry but I still really don't get it :( How do I do the array thing? _ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] Check Boxes/UPDATE
for( $i=0; $i3; $i++ ) { if( isset($chkAuthStatus[$i]) ) { do something } } -Original Message- From: Matt C [mailto:[EMAIL PROTECTED]] Sent: Wednesday, October 03, 2001 10:17 AM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: RE: [PHP-DB] Check Boxes/UPDATE I am sorry but I still really don't get it :( How do I do the array thing? -Original Message- From: Jason G. [mailto:[EMAIL PROTECTED]] Sent: 03 October 2001 12:12 To: Matt C; [EMAIL PROTECTED] Subject: Re: [PHP-DB] Check Boxes/UPDATE Matt, Assuming that you have a variable number of records being displayed out of the database: As you write out the HTML, give each checkbox a name containing the ID# of the record that is being written out. Ex: input type=check name=chkAuthStatus_1203 checked input type=check name=chkAuthStatus_1204 checked input type=check name=chkAuthStatus_1205 checked Note that you can use arrays when naming your form elements -- isn't PHP wonderful :). Thus you can have: input type=check name=chkAuthStatus[0] checked input type=check name=chkAuthStatus[1] checked input type=check name=chkAuthStatus[2] checked ...etc This simplifies the code somewhat as you can now loop through the elements of the array $chkAuthStatus to find out whether it is checked or not. regards -- Jason Wong Gremlins Associates www.gremlins.com.hk Tel: +852-2573-5033 Fax: +852-2573-5851 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] Check Boxes/UPDATE
-Original Message- From: Matt C [mailto:[EMAIL PROTECTED]] Sent: 03 October 2001 23:17 To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: RE: [PHP-DB] Check Boxes/UPDATE I am sorry but I still really don't get it :( How do I do the array thing? Please specify *which* part you don't understand -- the setting up of the form, or retrieving the info from the form? -- Jason Wong Gremlins Associates www.gremlins.com.hk Tel: +852-2573-5033 Fax: +852-2573-5851 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] Check Boxes/UPDATE
Hiya Matt you have to set the value of the checkbox to 1, and give it a unique name. if the user has checked the box when they submit the form then the checkbox' name will have a value of 1. if they didn't check it it won't have a value at all. Hope this helps! Dave -Original Message- From: Matt C [mailto:[EMAIL PROTECTED]] Sent: 03 October 2001 03:23 To: [EMAIL PROTECTED] Subject: [PHP-DB] Check Boxes/UPDATE I have a page of jobs with AuthStatus set to 0. Basically I want to list each job title with a checkbox next to it. This I have done. What I really don't understand is how do I make it so that the rows in my table for all the different records when ticked are updated to 1? Please help. Matt _ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Check Boxes/UPDATE
Matt, Assuming that you have a variable number of records being displayed out of the database: As you write out the HTML, give each checkbox a name containing the ID# of the record that is being written out. Ex: input type=check name=chkAuthStatus_1203 checked input type=check name=chkAuthStatus_1204 checked input type=check name=chkAuthStatus_1205 checked Use code like the following to Write and Read the web form... ?php //Get the DB result $dbResult = mysql_query(SELECT id, authstatus, whatever, whatever2 FROM table WHERE whatever); //Get the row count $nRowCount = mysql_num_rows($dbResult); //Scan the result for($i=0; $i$nRowCount; $i++) { //Get the current row as an object $oRow = mysql_fetch_object($dbResult); //Format the checkbox name $sCheckName = chkAuthStatus_ . $oRow-id; //When Writing out the Web Form, use this $sChecked = ($oRow-authstatus ? ' checked' : ''); echo input type=\check\ name=\$sCheckName\$sChecked; //When Reading in the web form, use this //If the checkbox variable isset(checked) then set the authstatus=1 //Otherwise set the authstat= 0 $authstatus = (isset($$sCheckName) ? 1 : 0); //Update the database mysql_query(UPDATE table SET authstatus=$authstatus WHERE id=$oRow-id); } ? -Jason Garber www.IonZoft.com At 03:22 AM 10/3/2001 +0100, Matt C wrote: I have a page of jobs with AuthStatus set to 0. Basically I want to list each job title with a checkbox next to it. This I have done. What I really don't understand is how do I make it so that the rows in my table for all the different records when ticked are updated to 1? Please help. Matt _ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]