如何使用关联数组从复选框中获取id并从文本字段中获取值

GUI

Hi everyone, i'm new to programming. I need to develop a rating system with check boxes and text-fields where user clicks the subjects from the list and add his rating/experience in the text field. All these subjects and ratings are added to the database with the subject id and the rating. So the issue is, I don't know how to write the associate array to get the selected subjects and their appropriate rating to insert into the database. Can anyone please provide me some codes or samples similar to this. So, I can get some idea how to do this. Thanks in advance :)

This is the HTML sample code

<form action="" method="post">
<table width="372" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="24"><input type="checkbox" name="subid1" value="1" id="subid1"></td>
    <td width="203">Maths</td>`enter code here`
    <td width="145"><input type="text" name="sub1" id="sub1"></td>
  </tr>
  <tr>
    <td><input type="checkbox" name="subid2" value="2" id="subid2" /></td>
    <td>Physics</td>
    <td><input type="text" name="subid2" id="subid2" /></td>
  </tr>
  <tr>
    <td><input type="checkbox" name="subid3" value="3" id="subid3" /></td>
    <td>Computing</td>
    <td><input type="text" name="subid3" id="subid3" /></td>
  </tr>
  <tr>
    <td><input type="checkbox" name="subid4" value="4" id="subid4" /></td>
    <td>Chemistry</td>
    <td><input type="text" name="subid4" id="subid4" /></td>
  </tr>
  <tr>
    <td><input type="checkbox" name="subid5" value="5" id="subid5" /></td>
    <td>Biology</td>
    <td><input type="text" name="subid5" id="subid5" /></td>
  </tr>
  <tr>
    <td><input type="checkbox" name="subid7" value="6" id="subid7" /></td>
    <td>Human Biology</td>
    <td><input type="text" name="subid6" id="subid6" /></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><input type="submit" name="button" id="button" value="Submit" /></td>
    <td>&nbsp;</td>
  </tr>
</table>
</form>

This will do the job on client side:

<input type="checkbox" name="cb[myID1]" value="1" />
<input type="text" name="t[myID1]" value="" />
<input type="checkbox" name="cb[myID2]" value="1" />
<input type="text" name="t[myID2]" value="" />

and this can be used on server side:

$usedTexts = array();
if ( array_key_exists("t", $_POST)  && is_array($_POST["t"])
  && array_key_exists("cb", $_POST) && is_array($_POST["cb"]) 
) 
{
  $usedTexts = array_intersect_key($_POST["t"], $_POST["cb"]);
}

see manual for server side: http://us3.php.net/array_intersect_key

edit: fixed to POST; added array_key_exists() and is_array()