I am looking for clarification on while loop and foreach loop...
say I have 2 tables both table have a field called MYID, MYID will be the same for both tables..
How would you accomplish echo certain fields once while another field multiple times.
example
while ($row = mysqli_fetch_assoc($result)) { $MYID = $row['MYID']; $FullName = $row['FullName']; $Photo = $row['Photo']; // Display this info once echo "<div>$FullName<br>Photo</div>"; // Array for table 2 row $Images[] = array($row['Images']); foreach ($Images as $img){ //Display this row as many times as needed by data in this row. echo <div>$img</div>; } }
$Imagescontains all the images from all the rows you've processed so far, not just the current row.$row['Images']contains a comma-separated list of images, you should useexplode()to split it into an array, and then loop over that.