Jump to content

Display picture with max date


runnerpaul

Recommended Posts

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.