echo the smallest id from a $row result

Place for questions and answers for all newcomers and new coders. This is a free for all forum, no question is too stupid and to noob.
Post Reply
floryn
Posts: 1
Joined: Fri Apr 24, 2015 6:23 am

echo the smallest id from a $row result

Post by floryn »

Code: Select all

<div id="poze">
<?php 

    $img_url = "http://fiestukis.site40.net/"; 
    $result = mysql_query("SELECT url FROM  images  where sid='$sid' Order by ID DESC limit 7 "); 
    while($row = mysql_fetch_assoc($result)) 
    { 
        echo '<img src="'.$img_url.$row['url'].'" border="0"  width="200" height="250" />';

    }
$num_rows = mysql_num_rows($result);

echo "$num_rows Rows\n";

?>
</div>
I have this code to list the photos stored in my data base. how do I echo out the id of each photo that shows and how do I echo the smallest id from the 7 results
User avatar
KyleMassacre
Posts: 573
Joined: Wed Nov 27, 2013 12:42 pm

Re: echo the smallest id from a $row result

Post by KyleMassacre »

You can probably just do something like using the min() function
Post Reply

Return to “Beginner Help and Support”