Jump to content

Fetching data using specific dates


ryanwood4

Recommended Posts

I'm using the below code to fetch the most recent 24 articles stored in the database. However, I need to change it, so it only fetches posts from the current day. So for example, today it would fetch the 15th October 2009 results, and tomorrow the 16th's. Is this possible?

 

<?php
$con = mysql_connect("xxxx","xxxx","xxxx");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("xxxx", $con);

$result = mysql_query("SELECT * FROM n2s_article ORDER BY article_id DESC LIMIT 0,23");

echo "<table class='links' border='0'>
<tr>
<th></th>
</tr>";

while($row = mysql_fetch_array($result))
  {
    $url = $row['article_url'] . "-" . $row['article_id'] . ".html";
    echo "<tr>";
    echo "<td class='link'><font face='verdana' size='1pt'>» <a href='$url'>".stripslashes($row['article_title'])."</a></td>";
    
  }

mysql_close($con);
?>[/code

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/177830-fetching-data-using-specific-dates/
Share on other sites

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.