Jump to content

Displaying Closest Date In The Future


Hilly_2004

Recommended Posts

Hi guys,

 

I've searched through the forums, and haven't found anything that might help me.

 

I have a field in a table called "Fixture_Date" with a 'date' type e.g. YYYY-MM-DD, does anyone know a select query that will select the next upcoming event based on the current date?

 

Thanks for any help you can throw my way!

Link to comment
https://forums.phpfreaks.com/topic/93901-displaying-closest-date-in-the-future/
Share on other sites

Cheers!

 

Works a treat. For anyone else wondering my script looks like:

 

<?php

//Load all fixtures from the database and then ORDER them by Date (nearest date displayed first)

$today = date("Y-m-d");

$result = mysql_query("SELECT * FROM tbl_fixtures WHERE Fixture_Date > '$today' ORDER BY Fixture_Date ASC LIMIT 1", $connect);

//Loop and Get All The Fixtures From The Database

while($myrow = mysql_fetch_array($result))
{

//Prints Results

echo "<p class=\"ColumnTitle\">";		   
echo $myrow['Opponent'];
echo "</p>";
}

?>				

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.