Note that there are some explanatory texts on larger screens.

plurals
  1. PODisplay image from server in a div (newest first) PHP
    primarykey
    data
    text
    <p>I want to display images in from server. In the database you can find the description and name of the image. the images should be displayed in a div where always the newest is on top. As the number of images increase so does the number of div's. so, the oldest will be at the bottom. I have read a number of posts and forums but I was unable to get the logic and the code on how to do it. I hope you can help me with my problem. Thanks a lot for your answer.</p> <p>the only code i have is the formatting of the dive's:</p> <pre><code>&lt;div class="gallery"&gt; &lt;div class= "group"&gt; &lt;div class="images"&gt; &lt;/div&gt; &lt;div class="details"&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class= "group"&gt; &lt;div class="images"&gt; &lt;/div&gt; &lt;div class="details"&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class= "group"&gt; &lt;div class="images"&gt; &lt;/div&gt; &lt;div class="details"&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>it's something like this:</p> <p>newest image | some details here</p> <p>newer image | some datails here</p> <p>new image | some details here</p> <p>old image | some details here </p> <p><strong>EDIT 1</strong></p> <p>I combined Lauri Elias' and iamde_coder's answer. I come up with this code which works almost similar to what is wanted. the only problem is that it displays the item (image&amp;details in a div) 4 times. How can I eliminate the three? thanks!</p> <pre><code>$image_query = mysql_query ("SELECT filename, story FROM tbl_contest ORDER BY time DESC"); while($image_data = mysql_fetch_array($image_query)){ $imageName = stripslashes(mysql_real_escape_string($image_data['filename'])); $imageDetails = stripslashes(mysql_real_escape_string($image_data['story'])); $count = 0; foreach($image_data as $imageName) { echo '&lt;div class="group"&gt;'; echo '&lt;div class="images"&gt;&lt;img src="/Mainfolder/image_entry/'.$imageName.'"&gt;&lt;/img&gt;&lt;/div&gt;'; echo '&lt;div class="details"&gt;'.$imageDetails.'&lt;/div&gt;&lt;/div&gt;'; $count ++; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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