Jump to content

Recommended Posts

I have this form that reads some info in a database that is available for inserting into another table. on each row I have a checkbox. I'd like to take the info out where there is a checkbox marked and insert into my table. Make sense? Any idea how to do this.

 

This is my form:

<form id="form1" name="form1" method="post" action="">
<table width="100%" border="0">
  <?php do { ?>
    <tr>
      <td><?php echo $row_rsSowCats['sowcatID']; ?></td>
      <td><?php echo $row_rsSowCats['sowCategory']; ?></td>
      <td>
        <input type="checkbox" name="checkbox" value="checkbox" />      </td>
      <td> </td>
    </tr>
    <?php } while ($row_rsSowCats = mysql_fetch_assoc($rsSowCats)); ?>
</table>
</form>

 

Not sure how to pull out the info that is selected in order to write into my simple query

$array =

$query="INSERT INTO table VALUES $array";

Link to comment
https://forums.phpfreaks.com/topic/54512-bulk-insert/
Share on other sites

the checkbox would have to have a name corresponding to whichever row you want it to effect.. such as:

<input type="checkbox" name="checkbox<?php echo $row_rsSowCats['sowcatID']; ?>" value="checkbox" />

 

then on your page for checking it have an isset check.

<?php
if(isset($_POST['checkbox1'])){
    //the checkbox is checked
}else{
   //the checkbox is not checked
}
?>

obviously if you don't want to do this for every checkbox you could use a foreach statement to go thrtough them

Link to comment
https://forums.phpfreaks.com/topic/54512-bulk-insert/#findComment-269621
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.