array of checkboxes?

From: Date: Tue, 16 Apr 2002 23:07:28 +0000
Subject: array of checkboxes?
Groups: php.general 
Request: Send a blank email to php-general+get-93266@lists.php.net to get a copy of this message
I'm trying to apply/update a database using a form on a previous page that uses checkboxes instead of edit fields, and I'm having trouble getting the correct values from the checkboxes. My form: printf( "<TD align='center'>" ); if( $row["approved"] == 1 ) { printf( "<INPUT type='checkbox' name='approved[]' value='ON' checked>" ); } else { printf( "<INPUT type='checkbox' name='approved[]'>" ); } printf( "</TD>" ); then calls a php file which contains: /* process the periods and update */ $num_rows = count( $id ); for( $i = 0; $i < $num_rows; $i++ ) { if( $approved[$i] == 'ON' ) { $appr = 1; } else { $appr = 0; } /* run the sql statement here */ $sql_str = "update ". "allotee_approval ". "set ". "pct_ownership = $pct_ownership[$i], ". "approved = $appr ". "where ". "log_unit = $form_log_unit and ". "scale_unit = $form_scale_unit and ". "id = '$id[$i]' "; Jeff. -- Jeff D. Hamann Hamann, Donald & Associates, Inc. PO Box 1421 Corvallis, Oregon USA 97339-1421 Bus. 541-753-7333 Cell. 541-740-5988 jeff_hamann@hamanndonald.com www.hamanndonald.com

« previous php.general (#93266) next »