runnerpaul Posted February 5, 2011 Share Posted February 5, 2011 Hi, I have the following table: ID picName description date 1 Us Time.jpg A couple watching the sunset at Ballintoy Harbour 2011-02-04 2 Pic.jpg This is the house on Castle Island taken in fog. 2011-02-03 3 catblack.jpg Pic of a cat 2011-02-05 I am trying to display th picName that belongs to the highest date but only know how to display all pictures. Can anybody help me? Here is what I have: <?php include("db.inc"); $cxn = mysqli_connect($host,$user,$password,$dbname) or die ("couldn't connect to server"); /* Select */ $query = "SELECT * FROM pictures"; $result = mysqli_query($cxn,$query) or die ("Couldn't execute query."); while($row = mysqli_fetch_assoc($result)) { echo "<tr><td colspan=2> </td> <td><img src='./images/{$row['picName']}' border='0' width='500' height='400' /><p></td></tr>\n"; } ?> Link to comment https://forums.phpfreaks.com/topic/226769-display-picture-with-max-date/ Share on other sites More sharing options...
sottwell Posted February 5, 2011 Share Posted February 5, 2011 $query = "SELECT * FROM pictures ORDER BY date LIMIT 1"; Link to comment https://forums.phpfreaks.com/topic/226769-display-picture-with-max-date/#findComment-1170196 Share on other sites More sharing options...
runnerpaul Posted February 5, 2011 Author Share Posted February 5, 2011 Ah thats great. Cheers. If I then wanted to add a link that pulls a picture where date is equivalent to the current date selected - 1 day. i.e. the picture from the previous day. Apolgies if this is simple or obvious. I havnt looked at php in 6 years and havnt a clue about it. Link to comment https://forums.phpfreaks.com/topic/226769-display-picture-with-max-date/#findComment-1170218 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.