php - How to Fetch data from while loop inside a while loop -


i have code , thing it's weird when last_name first query unique number , of spell of last name table when try data below second ends thinks first while loop has ended , can't rest of data first while loop , tried code unfortunately didn't worked me

<div class="row">     <?php      $sql2 = "select id,last_name,age,height,weight,gender,education,work              profile parent_key!='$parent_key' ";     $retval2 = mysqli_query($con,$sql2);      if(! $retval2 ) {         die('could not data: ' . mysql_error());     }      while($row = mysqli_fetch_array($retval2, mysql_assoc)) {     ?>      <div class="row">         <div class="col-lg-6 col-md-6 col-sm-6">             <span>unique id</span>             <h3><?php  echo $row['id'] ?></h3>         </div>     <div class="col-lg-6 col-md-6 col-sm-6">         <span>surname</span>         <h3><?php $surname = $row['last_name'];              $sql3 = "select last_name surname id='$surname'";             $retval3 = mysqli_query($con,$sql3);             if(! $retval3 ) {                 die('could not data: ' . mysql_error());             }             while($row = mysqli_fetch_array($retval3, mysql_assoc)) {                 echo $new_last_name ="{$row['last_name']}";             ?>             ?>         </h3>     </div>  </div> <!-- /.row -->   <!-- /.row -->  <?php     } ?>  <?php     } ?> </div> <!-- /.row --> 

and helping in advance.

inside of second while loop change :

$row = mysqli_fetch_array($retval3, mysql_assoc) 

to

$row1 = mysqli_fetch_array($retval3, mysql_assoc) 

then can use values first while $row['columnname'] , second while $row1['columnname']


Comments