Topic: help with inserting checkbox form values. (Read 761 times)
Google dot what?
Posts: 2
16 credits Members referred : 0
« on: Aug 16, 2007, 06:13:59 AM »
i have a form that grabs data and displays it as a checkbox list. it pulls data from another table and displays this list as radio buttons.
I want to be able to select one radio button and multiple checkboxes, then have these values inserted into a third table. My form is generated correctly (as far as i can tell) I am having trouble with how in the heck get the multiple checkboxes which are selected to insert there values into the table.
Form is as follows - this generates the checkboxes (a thumbnailed picture with a check box below and a title)
Code:
$result = mysql_query("SELECT * FROM pictures"); $output="<tr>"; while($row = mysql_fetch_array($result)) { $counter = $counter + 1; $output .="<!--START ROW FOR checkbox " .$row['fileName']." --> "; $output .=" <td width=10 id=left10 align=left ><!--".$counter."--><br></td>"; $output .=" <td width=120 id=middle align=center valign=top >"; $output .=" <a href=".$fileURL."".$row['fileName']." ><img src=".$fileURL."THUMBS/".$row['fileName']." ></a><br>"; $output .=" <input type=checkbox name=PICTURES[] value=".$row['fileName']." />".$row['picTitle']." "; $output .=" </td>"; $output .=" <td width=10 id=right10 ><br></td>"; $output .="<!-- END ROW FOR checkbox " .$row['fileName']." -->"; if ( $counter % 4 == 0 ) { $output .= "</tr><tr>"; } } $output .="</tr>"; // open the file $fhandle = fopen( "FormParts/pictureCheckBoxes.php", "w" ); // write the contents of the $output variable to the file fwrite( $fhandle, $output ); // close the file fclose( $fhandle ); include('FormParts/pictureCheckBoxes.php');
the radio is here:
Code:
$result = mysql_query("SELECT * FROM persons"); $output="<tr>"; while($row = mysql_fetch_array($result)) { $counter = $counter + 1; $output .="<!-- START ROW FOR Radio " .$row['name']."--> "; $output .=" <td width=10 id=left10 align=left valign=top >".$counter.". "; $output .=" </td>"; $output .=" <td width=120 id=middle align=left valign=top >"; $output .=" <input type=radio name=PERSONS value=".$row['name']." >".$row['name']; $output .=" </td>"; $output .=" <td width=10 id=right10 valign=top ></td>"; $output .="<!-- END ROW FOR Radio " .$row['Name']."--> "; if ( $counter % 1 == 0 ) { $output .= "</tr><tr>"; } } $output .="</tr>"; // open the file $fhandle = fopen( "FormParts/personsBullets.php", "w" ); // write the contents of the $output variable to the file fwrite( $fhandle, $output );