Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>My previous answer is not correct, but still valid because you never use "imagenum". And return still must be outside the while.</p> <p>Anyway the reason you get always the same image is that you're using always the same array element.</p> <p>Try:</p> <pre><code>$i=0; foreach ($images as $image) { If($i=0) { ?&gt; &lt;table id="thumbnails"&gt; &lt;tr&gt; &lt;td&gt; &lt;?php //Add image title to the right of main image... echo '&lt;a href="testdrive.php" style="text-decoration:none"&gt;&lt;img src="uploads/', $image['vehicleid'], '/', $image['imageid'], '.', $image['ext'], '" title="Uploaded ', date('D M Y / h:i', $image['timestamp']), ' - ', $year, ' ', $manufacturer, ' ', $modelrange, ' ', $modelder, '.', 'This beautiful ', $colour, ' ',$manufacturer, ' only has ', $mileage, ' kilometres and is selling for ', 'ONLY R ', $price, '.', '" width="600px" height="400px" /&gt;&lt;/a&gt;'; ?&gt; &lt;/div&gt; &lt;/td&gt; &lt;td&gt; &lt;table width="350px"&gt; &lt;tr height="50px"&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;div id="mainimages" align="center" style="font-size:14px"&gt; &lt;?php echo $year, ' ', $manufacturer, ' ', $modelrange, ' ', $modelder, '.', '&lt;br /&gt;', '&lt;br /&gt;', 'This beautiful ', $colour, ' ',$manufacturer, ' only has ', $mileage, ' kilometres with a service history and is selling for ', '&lt;strong&gt;ONLY R ', $price, '. &lt;/strong&gt;', '&lt;br /&gt;', '&lt;br /&gt;', 'It features ', $comments, '&lt;br /&gt;', '&lt;br /&gt;', 'This vehicle is available NOW from our ', '&lt;a href="testdrive.php" style="text-decoration:none"&gt;', 'Tata - ', $branch, ' branch.&lt;/a&gt;'; ?&gt; &lt;/div&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;div id="mainimages" align="center" style="font-size:14px"&gt; &lt;?php echo '&lt;a href="delete_image.php?vehicle_id='.$vehicleid.'"&gt;&lt;img src="images/delete.png" title="Delete Advert" /&gt;&lt;/a&gt;'; ?&gt; &lt;/div&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;?php $i=1; } else {//THIS WHERE I NEED TO START LOADING THE CORRECT IMAGES - THIS SHOULD BE IMAGE RETURNED FROM RECORD 2... echo '&lt;a href="testdrive.php" style="text-decoration:none"&gt;&lt;img src="uploads/thumbs/', $image['vehicleid'], '/', $image['imageid'], '.', $image['ext'], '" title="Uploaded ', date('D M Y / h:i', $image['timestamp']), ' - ', $year, ' ', $manufacturer, ' ', $modelrange, ' ', $modelder, '.', 'This beautiful ', $colour, ' ',$manufacturer, ' only has ', $mileage, ' kilometres and is selling for ', 'ONLY R ', $price, '.', '" onclick="showImage("uploads/', $image['vehicleid'], '/', $image['imageid'], '.', $image['ext'], '" width="100px" height="100px")" /&gt;&lt;/a&gt;'; ?&gt; &lt;?php } } } ?&gt; &lt;p style="height:10px"&gt;&lt;/p&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p>Or something similar (it's difficult to write code in the stackoverflow editor).</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload