jeudi 8 juin 2017

Keep array of checkboxes checked PHP

Here's my code:

while($row = mysql_fetch_array($result))
  {
  echo "<tr>";
  echo "<td>" . $row['u_block'] . "</td>";
  echo "<td>" . $row['u_building'] . "</td>";
  echo "<td>" . $row['u_area'] . "</td>";
  echo "<td>" . $row['u_state'] . "</td>";
  echo "<td>" . $row['u_town'] . "</td>";
  echo "<td>" . $row['u_pincode'] . "</td>";
  echo "<td>" . $row['u_country'] . "</td>";
  echo "<td>" . $row['u_sel'] . "</td>";
  if($row['approved']==1)
       echo "<td>" . "Approved" . "</td>";
 else
       echo "<td>" . "Pending" . "</td>";
  echo "<td><input type='checkbox' name='check[$i]' value='".$row['ID']."' />";

  echo "<input class='action' type='submit' name='approve' value='Approve' />";
 echo "<td><input type='checkbox' name='check[$i]' value='".$row['ID']."'/>"; 
  echo "<input class='action' type='submit' name='delete' value='Delete' />";
  echo "</tr>";
  $i++;
  }

This creates a table with information and approve and delete checkboxes. I want to keep the checkboxes 'checked' after I click on a checkbox and refresh the page. Please help!




Aucun commentaire:

Enregistrer un commentaire