-1

I have a list of checkbox (I need to give an id to each), then to make POST to another page

I have a while loop that which brings me one checkbox for each item in the database, I need to make each checkbox to make the POST, on the other page one check or X displays

Edit page.php

while ($fila = mysql_fetch_array($rs)) {
  echo "<td > <input type='checkbox' /> </td>}

AnotherPage.php

I guess I have to give an id to each checkbox to make the post and to get on another page.

Image trying to explain that I need

halfer
  • 19,824
  • 17
  • 99
  • 186
Gil
  • 43
  • 7
  • 4
    give `name` property to checkboxes, to get them in `POST` – Parixit Dec 03 '15 at 08:04
  • but if I give it a name not all change when you post? I need to show only who was checked – Gil Dec 03 '15 at 08:12
  • Hi there. There are some helpful answers below, did any of them assist in your difficulty? If so, please consider upvoting any of them, and/or accepting one of them. – halfer Jan 11 '16 at 20:37

3 Answers3

0

This seems to be a duplicate of this question: Get $_POST from multiple checkboxes

See the checked answer there.

The main thing in PHP based applications is that a form element with a name with name[] (square brackets at the end) will result in an array in the receiving PHP script. That allows you to have all the values the user selected.

Community
  • 1
  • 1
narcoticfresh
  • 257
  • 4
  • 10
0

There must be something like this

<form action="AnotherPage.php" method="post">
<input type="checkbox" name="check1" value="1">
</form>

And then in php

if (!empty($_POST['check1'])) {
// make your logic
}
Alex
  • 11
  • 1
0
<?php
while ($fila = mysql_fetch_array($rs)) {
  <td> <input type='checkbox' name='CheckBoxName[]' value="<?echo $fila['GiveValueHere'];?>"/> </td>
}?>

SomePage.php (Submit Page)

<?

$totalCheckBoxChecked=sizeof($_POST['CheckBoxName']);

for($i=0;$i<$totalCheckBoxChecked;$i++)
{
    echo $checkBoxValue=$CheckBoxName[$i];
    echo "<br>";
}
?>
Nana Partykar
  • 10,556
  • 10
  • 48
  • 77