title: Modal inside PHP while loop with delete and edit only returns the ticket of the 1st row
body: <p>I am displaying tickets and used while loop to display each on a table. Edit button is working fine for each loop however for the delete button I can't seem to pass the value of the ticket that I specifically want to delete. Function goes like this once the delete button is clicked it will go to a modal for confirmation of deletion but it always deletes the 1st row. I need to get the specific value of the ticket to pass to deleteconfirm.php Below is the code that I have used.</p>
  
  <pre><code> $stats = $_REQUEST['stats'];
   $query20 ="SELECT * FROM user WHERE status='$stats' ORDER BY date_received 
   DESC";
  
   $result2 = mysqli_query($datalog,$query20);
  
        while( $row = mysqli_fetch_assoc( $result2 ) ){ 
  
  
          if($row['task5']!=''){
  
            $tasks = $row['task'].'/'.$row['task1'].'/'.$row['task2'].'/'.$row['task3'].'/'.$row['task4'].'/'.$row['task5'];
          }
            elseif($row['task4']!=''){
  
            $tasks = $row['task'].'/'.$row['task1'].'/'.$row['task2'].'/'.$row['task3'].'/'.$row['task4'];
          }
               elseif($row['task3']!=''){
  
            $tasks = $row['task'].'/'.$row['task1'].'/'.$row['task2'].'/'.$row['task3'];
          }
                 elseif($row['task2']!=''){
  
            $tasks = $row['task'].'/'.$row['task1'].'/'.$row['task2'];
          }
                      elseif($row['task1']!=''){
  
            $tasks = $row['task'].'/'.$row['task1'];
          }
                        elseif($row['task']!=''){
  
            $tasks = $row['task'];
          }
  
  
  
          echo
          "&lt;tr&gt;
  
            &lt;td&gt;{$row['ticket']}&lt;/td&gt;
            &lt;td&gt;{$row['date_received']}&lt;/td&gt;
            &lt;td&gt;{$row['subject']}&lt;/td&gt;
            &lt;td&gt;{$row['property']}&lt;/td&gt;
            &lt;td&gt;$tasks&lt;/td&gt;
            &lt;td&gt;{$row['territory']}&lt;/td&gt;
            &lt;td&gt;{$row['loadername']}&lt;/td&gt;
            &lt;td&gt;{$row['seniorname']}&lt;/td&gt;
            &lt;td&gt;{$row['qaname']}&lt;/td&gt;
  
           &lt;td&gt;&lt;a href=editticket.php?supe=".$row['ticket']."  target='_top'&gt; 
           &lt;span class='glyphicon glyphicon-edit'&gt;&lt;/span&gt;&lt;/a&gt;
           &lt;button class='open-homeEvents' id='btnPopModal' href='#' data- 
           toggle='modal' data-target='#confirmdelete' data- 
            id=".$row['ticket']." &gt;  &lt;span class='glyphicon glyphicon-trash' 
            style='color:red'&gt;&lt;/span&gt;&lt;/button&gt;";
  
           echo"
  
            &lt;div class='modal fade' id='confirmdelete' role='dialog'&gt;
               &lt;form method='POST' action='deleteconfirm.php' id='delcon' &gt;
  
            &lt;div class='form-group'&gt;
             &lt;div class='modal-dialog'&gt;
  
             &lt;div class='modal-content'&gt;
             &lt;div class='modal-header'&gt;
              &lt;button type='button' class='close' data-dismiss='modal'&gt;&amp;times; 
             &lt;/button&gt;
              &lt;h4 class='modal-title'&gt;Confirm Delete&lt;/h4&gt;
              &lt;/div&gt;
  
              &lt;div class='modal-body'&gt;
              &lt;p&gt;Are you sure you want to Delete Ticket &lt;b&gt; &lt;input 
        type='hidden' name='eventId' id='eventId'/&gt;
        &lt;span id='idHolder' name='idHolder'&gt;&lt;/span&gt; 
               &lt;/b&gt;?&lt;/p&gt;
              &lt;p&gt;If Yes please confirm indicating reason below:&lt;/p&gt;
  
              &lt;p&gt;&lt;textarea id='res' name='res' required&gt;&lt;/textarea&gt;&lt;/p&gt;
                  &lt;input hidden id='delc' name='delc' value=".$row['ticket']." 
             /&gt;
              &lt;/div&gt;
              &lt;div class='modal-footer'&gt;
              &lt;button class='btn btn-default'  href='#' type='submit' 
             target='_parent'&gt;Yes&lt;/button&gt;
  
              &lt;button type='button' class='btn btn-default' data- 
              dismiss='modal'&gt;No&lt;/button&gt;
              &lt;/div&gt;
  
              &lt;/div&gt;
  
              &lt;/div&gt;
              &lt;/div&gt;
              &lt;/div&gt;
              &lt;/form&gt;
  
  
  
           &lt;/td&gt;
          &lt;/tr&gt;\n";} ?&gt;
  </code></pre>
  
  <p>Below is the code for deleteconfirm.php</p>
  
  <pre><code>&lt;?php
  
  session_start();
  
  require_once('datalog.php');
  
  $delc=$_POST['delc'];
  $tak= $_POST['tak']; 
  $res=$_POST['res'];
  
  
  
  
  
    if(isset($_REQUEST['delc'])&amp;&amp;$_REQUEST['delc']!=''
    &amp;&amp;isset($_SESSION['SESS_USER_NAME'])){
  
  
             $tickets=$delc;
             $delid=$_SESSION['SESS_USER_NAME'];
             $query22="SELECT * from memberinfo WHERE username='$delid'";
             $result22=mysqli_query($datalog,$query22);
               while( $row1 = mysqli_fetch_assoc( $result22 ) ){
  
                  $delby=$row1['full_name'];
  
               }
  
                  $query23="SELECT * from user WHERE ticket='$delc'";
             $result23=mysqli_query($datalog,$query23);
              while( $row = mysqli_fetch_assoc( $result23 ) ){
              $subject= $row['subject'];
              $property= $row['property'];
              $country= $row['country'];
              $city= $row['city'];
              $validity= $row['validity'];
              $remarks= $row['remarks'];
              $priority= $row['tagging'];
              $territory= $row['territory'];
              $status= $row['status'];
              $date_received= $row['date_received'];
              $loader= $row['loadername'];
              $senior= $row['seniorname'];
              $qa= $row['qaname'];
             }
  
             $query1="INSERT INTO deletehistory (iddeleted_by,deleted_by,deletereason,subject,property,task,country,city,validity,remarks,ticket,priority,status,date_received,loader,qa,senior,territory) values ('".$delid."','".$delby."','".$res."','".$subject."','".$property."','".$tak."','".$country."','".$city."','".$validity."','".$remarks."','".$delc."','".$priority."','".$status."','".$date_received."','".$loader."','".$qa."','".$senior."','".$territory."')";
             $result1=mysqli_query($datalog,$query1);
  
  
  
          }  
  
  
              $query4="DELETE FROM user WHERE ticket='$delc' ";
            $result4=mysqli_query($datalog,$query4);
              header("location: delete.php");
  ?&gt; 
  </code></pre>
  
  <p>Hope someone can enlighten me on this one, Thanks in advance!</p>