mysql - How to get value of an input if checkbox in that row is clicked in PHP -


in code have show row mysql , @ end have input put in date , insert database. cannot figure out how make updates each input individually each checked box row.

$i = 0; while($row = $result->fetch_assoc()) {    echo  "<div class='row'>     <div class='col-md-10 col-offset-1'>     <tr>     <td>     <input type='checkbox' name='chk1[$i]' value='".$row['customerid']."' /> " .$row['firstname']." ".$row['lastname'].      "</td>     <td>"  .     $row['phonenumber'].     "</td>      <td>" .$row['brand'].     "</td>     <td>" .$row['stock'].     "</td>     <td>" .$row['shoename'].     "</td>     <td>" .$row['size'].$row['width']. "</td>";      echo "<td><input name='backorder' type='date'/></td>     <td id='comments'>" .$row['comment']. "</td>      </div>     </div>"; $cid[$i] = $row['customerid']; $i++; } 

so when update below updates fine gives rows in database same value backorder.

if(isset($_post['chk1'])) {     foreach($_post['chk1'] $cid[$i]) {         $chk1[] = array($cid[$i]);         if(!empty($chk1)) {              //include("email.php");             $sql = "select * shoes customerid =" .$cid[$i];             $result = $conn->query($sql);              if ($result->num_rows > 0) {                 // output data of each row                 while($row = $result->fetch_assoc()) {                     $texting = $row['texting'];                     $name = $row['firstname'];                     $email = $row['email'];                     $provider = $row['provider'];                     $brand = $row['brand'];                     //$sql must in loop in order execute checkboxes.                      $sql = "update shoes set ordered=curdate(), backorder='backorder' customerid=".$cid[$i]; 

your sql sends static string value update of field.

$sql = "update shoes set ordered=curdate(), backorder='backorder' customerid=".$cid[$i]; needs updated use variable value or string "backorder" become value updated.


Comments