php - Need to Insert Multiple Data by selecting Checkboxes -


i need insert data db using form given below

<form action="othereventpayment.php" id="frmsignin" method="post">       <input  type="hidden" name="online_id" value="<?php echo $lid; ?>" >             <table class="table">     <thead>         <tr>             <th>#</th>             <th>item</th>             <th>no. of participants</th>             <th>tick items</th>         </tr>         </thead>     <tbody>      <tbody>  <?php $sn ="1"; $id = $oth_event_id; $stmt1 = $db_con->prepare('select * oth_events_details                              left join oth_event_category on (oth_events_details.oth_evcat_id=oth_event_category.oth_evcat_id)                             oth_event_id =:uid order oth_event_det_id desc'); $stmt1->execute(array(':uid'=>$id)); $stmt1->execute(); if($stmt1->rowcount() > 0) {     while($row1=$stmt1->fetch(pdo::fetch_assoc))      {          extract($row1);         ?>         <tr>         <td><?php echo $sn; ?></td>         <td>          <?php  echo $row1['oth_category'];?> -         <?php             $group =$row1['oth_catgroup_type'];                      if ($group=="s")                     {                         echo "single";                     }                     elseif ($group=="d")                     {                         echo "doubles";                     }                     else{                          echo "group";                      }           ?>          </td>          <td><?php echo $row1['participntno']; ?></td>          <td>         <b>            </b>          <input type="checkbox" name="chk[<?php echo $row1['oth_event_det_id'];?>]" value="<?php echo $row1['oth_event_det_id'];?>" id="chk[<?php echo $row1['oth_event_det_id'];?>]" />         &nbsp;&nbsp;&nbsp;fees:-&nbsp;&nbsp;<?php echo $row1['oth_ev_fee'];?>          </td>             </tr>         <?php $sn++; ?>          <?php     }     }     else     {     ?>     <div class="col-xs-12">         <div class="alert alert-warning">             <span class="glyphicon glyphicon-info-sign"></span> &nbsp; no data found ...         </div>     </div>     <?php     }      ?>        </tbody>       </table>             <div class="col-md-6">     <input type="submit" name="selectitems" value="submit & proceed" class="btn btn-primary pull-right mb-xl" data-loading-text="loading...">     </div>     </div>     <?php echo $sn1=$sn-1; ?>     </form> 

in othereventpayment.php have written code. not working . how insert data correctly db

    <?php require_once 'dbconfig.php';    if(isset($_post['selectitems'])) {   echo array[] = $_post['chk[]'];    echo $oth_online_id= $_post['online_id'];      if($oth_event_detid != ""){     for($i=0;$i<sizeof($oth_event_detid);$i++)     { // oth_event_det_id,oth_online_id      $stmt = $db_con->prepare('insert othevents_itemsonline(oth_event_det_id,oth_online_id) values( :oth_event_det_id, :oth_online_id)');     $stmt->bindparam(':oth_event_det_id',$oth_event_det_id);     $stmt->bindparam(':oth_online_id',$oth_online_id);         if($stmt->execute())             {                 $lastonlineid= $db_con->lastinsertid();                   $successmsg = "thank registering . please select items participating...";                  // header("refresh:0;othereventsonlineregistrationthankyou.php"); /             }             else             {                 $errmsg = "error while registering....";             } } }        }  ?> 

name should same input field. use following code:

<input type="checkbox" name="chk[]" value="<?php echo $row1['oth_event_det_id'];?>" id="chk[<?php echo $row1['oth_event_det_id'];?>]" />     &nbsp;&nbsp;&nbsp;fees:-&nbsp;&nbsp;<?php echo $row1['oth_ev_fee'];?> 

you can see name. clear enough :p


Comments

Popular posts from this blog

python - Selenium remoteWebDriver (& SauceLabs) Firefox moseMoveTo action exception -

html - How to custom Bootstrap grid height? -

transpose - Maple isnt executing function but prints function term -