How to take a form's checkboxes and turn them into an array to update a mysql database with php

I have a form that has rows in a table that will post to itself.
Each row has a checkbox with an ID to be used to insert or update a mysql table with data from other form parts,
For example: SIDs 38, 39 and 33 are to be updated with status='paid' , forMonth = 'Apr', amount = '8000'.

How do I create an array of the SIDs that I can use in a mysql insert/update statement?
Note that it might be that later, I will have in the table, along with the checkboxs, a dropdown that has typical amounts that are overpaid, which could be different between each SID.
<form name='theTable' METHOD='POST' ACTION='' >
		<SELECT NAME='status'>
			<OPTION value = 'tuition' selected>PAID</option>
			<OPTION value = '10000'>OVERPAID</option>
			<OPTION value = '0'>VACATION</option>
		</SELECT>

			<input type="radio" name="genre" value="Jan"}	>Jan&nbsp; 
      
			<input type="radio" name="genre" value="Feb"}	>Feb&nbsp; 
      
			<input type="radio" name="genre" value="Mar"}	>Mar&nbsp; 
      
			<input type="radio" name="genre" value="Apr"}	>Apr&nbsp; 
      
			<input type="radio" name="genre" value="May"}	>May&nbsp; 
      
			<input type="radio" name="genre" value="Jun"}	>Jun&nbsp; 
      
			<input type="radio" name="genre" value="Jul"}	>Jul&nbsp; 
      
			<input type="radio" name="genre" value="Aug"}	>Aug&nbsp; 
      
			<input type="radio" name="genre" value="Sep"}	>Sep&nbsp; 
      
			<input type="radio" name="genre" value="Oct"}	>Oct&nbsp; 
      
			<input type="radio" name="genre" value="Nov"}	>Nov&nbsp; 
      
			<input type="radio" name="genre" value="Dec"}	>Dec&nbsp; 

<INPUT TYPE='submit' class='positive' VALUE='Update Selected Items' />

<table id="test2" cellpadding="0" cellspacing="0" border="0" class="rowstyle-alt colstyle-alt no-arrow paginate-40">
<thead>  <tr>
    <th>Modify</th><th class='sortable-text datatype-text'>Name</th><th class='sortable-text datatype-text'>Last Name</th><th>Tuition</th><th>Month</th><th>Edit</th>
  </tr></thead>
    <tr class='alt'>
	 <td><center><input type='checkbox' class='field checkbox' name='29' id='29' value='29'></center></td>
      <td>Akamichi</td>
      <td>Tosaki</td>
      <td>8000</td>
<td>      Mar, </td>  <td><a href='3b1.php?sid=29'>EDIT</a></td>
    </tr>    <tr class='alt'>
	 <td><center><input type='checkbox' class='field checkbox' name='17' id='17' value='17'></center></td>
      <td>Wakana</td>
      <td>Tsubaki</td>
      <td>8000</td>
<td>      Apr, </td>  <td><a href='3b1.php?sid=17'>EDIT</a></td>
    </tr></table>
</form>

Open in new window

kaileeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ray PaseurCommented:
Can you please clarify the question?  I'm not sure what you're asking and my answer may be off base, but I'll try.

This statement may not work out well because of the curly brace:
<input type="radio" name="genre" value="Jan"}      >Jan&nbsp;

To pass an array of elements in an HTML form to a PHP script, you use notation similar to JavaScript array notation.  You can use the square brackets on the end of the request element name.  You can put a string inside the square brackets to give named keys to the array, or you can just leave them empty and you'll get a numerically indexed array.

Here is an example:
http://iconoun.com/demo/form_checkbox_arrays.php
<?php // demo/form_checkbox_arrays.php
/**
 * Demonstrate how to use an array of checkboxes in a form
 */
error_reporting(E_ALL);

// IF ANYTHING WAS POSTED, SHOW IT
if (!empty($_POST))
{
    echo '<pre>';
    var_dump($_POST);
    echo '</pre>';
}

// CREATE A FORM FOR EXPERIMENTS WITH CHECKBOXES
$form = <<<ENDFORM
<form method="post">

These checkboxes have the name "box"
<br>
<input name="box[red]" type="checkbox" />Red
<input name="box[grn]" type="checkbox" />Green
<input name="box[blu]" type="checkbox" />Blue
<br><br>

These checkboxes have the name "nbr"
<br>
<input name="nbr[]" type="checkbox" />Zero
<input name="nbr[]" type="checkbox" />One
<input name="nbr[]" type="checkbox" />Two
<br><br>

These checkboxes have the name "ray"
<br>
<input name="ray[]" type="checkbox" value="sml" />Small
<input name="ray[]" type="checkbox" value="med" />Medium
<input name="ray[]" type="checkbox" value="lge" />Large
<br><br>

<input type="submit" />
</form>
ENDFORM;

echo $form;

Open in new window

0
kaileeAuthor Commented:
yea, I wound up changing the form element's name in order to create an array.  I then looped through it on return to the page to ensure I was capturing the data properly.  I'm now working on poking it into the database.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ray PaseurCommented:
Those are the right steps in the right order.  Best of luck with it!
0
Ray PaseurCommented:
Wow, we have a tested and working code example, and the Author posts a statement that they followed the guidance in th example -- and... wait for it... What's the point in answering questions at E-E any more?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.