how can I get data in the table cell that is checked after submit

Posted by arnold on Stack Overflow See other posts from Stack Overflow or by arnold
Published on 2009-11-30T10:43:29Z Indexed on 2010/03/14 12:05 UTC
Read the original article Hit count: 335

Filed under:
|
|

can someone give me help, please.

here's my basic html

<form action="addSomething.php" method="POST">
<table>
 <tr>
   <th>Add Data</th>
   <th>Description</th>
   <th>Quantity</th>  
</tr>

 <tr>
  <td><input type="checkbox" name="data[]" value="sample1" /> </td>
  <td class="desc">Newbie</td>
  <td>2</td>
 </tr>

<tr>
<td><input type="checkbox" name="data[]" value="sample1" /> </td>
<td class="desc">Pro</td>
<td>1</td>
</tr>

<tr>
<td><input type="checkbox" name="data[]" value="sample1"/> </td>
<td class="desc" > Master </td>
<td>1</td>
</tr>

<br/>
     <input type="submit" name="add" value="SUBMIT"/>
.....

how can I get the one with the class "desc" and the column for quantity that is checked after submitting the form

because the only I can add when querying in mysql is the value of checkbox but I want also the value of the data in "Description" column and "Quantity" column

In my addSomething.php the code I have is

 if(isset($_POST['add']))
      {

           foreach($_POST['data'] as $value)
           {

           $sql = "INSERT INTO tablename (column1) VALUES('$value');"

                //query stuff
            }

      }

what I will do , Any hints guys?

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql