Which check box was selected
<p>I have four rows per page. four rows which are parsed directly form mysql table. each row has a check box. I want to know which check box was selected .in the bellow code it is saving the first row of the page only. so if i select the third row it will show as the first row selected. I'm using onchange method to know that something was selected but which one i don't know how to get it yet.
Could someone help   </p>

<pre><code>&lt;?php

    //limit for number of categories displied per page
    $limit = 4;

    $categoriesNum= mysql_query("SELECT COUNT('categoryTopic') FROM categories");   

    //number of current page
    $page =(isset($_GET['page']))? (int) $_GET['page'] :1;

    //calculate the current page number 
    $begin =($page - 1)* $limit; 

    //number of pages needed. 
    $pagesCount =ceil(mysql_result ($categoriesNum,0)/$limit);

    //Query up all the Categories with setting the Limit 
    $CategoryQuery = mysql_query ("SELECT categoryTopic From categories ORDER BY categoryTopic LIMIT $begin, $limit");

    //Place all categories in an array then loop throuhgt it diaplaying them one by one
    while ($query_rows = mysql_fetch_assoc($CategoryQuery))
    {

        $category =$query_rows['categoryTopic'];  
        //echo $category; 
        //qurery all the subcategories that the current category has 
        $Sub = mysql_query ("SELECT categoryTopic FROM subcategories WHERE categoryTopic='$category'");             
        $Count = mysql_num_rows ($Sub); 

        echo  '&lt;table width="85%" border="1"  cellpadding="0"; cellspacing="0" align="center"&gt;

        &lt;tr&gt;        
            &lt;th width="23%" height="44" scope="col" align="left"&gt; '.$query_rows['categoryTopic'].' &lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;/th&gt;
            &lt;th width="24%" scope="col"&gt;'.$Count.'&lt;/th&gt;
            &lt;th width="25%" scope="col"&gt; 0 &lt;/th&gt;
            &lt;th width="28%" scope="col"&gt; &lt;form  name = "choose"&gt;
            &lt;label&gt;&lt;input type="checkbox" id ="check" value= '.$category.' onchange="handleChange(this);"&gt;&lt;/label&gt;
        &lt;/tr&gt;
    &lt;/table&gt;';  
    }
    ?&gt; 
</code></pre>

<p>
    //this funciton will be called when user checks a check box. </p>

<pre><code>function handleChange(cb) {

//get the selected category 
var category = document.getElementById('check').value; 
document.write(category); 
</code></pre>
