Limit Function Question
Posted: Sat Nov 22, 2008 8:42 pm
I am making a script in which a person is able to post things to an online weblog. The user submits a form and its added to the database. I am using this code to retrieve data from my database, and put it on my main page.
However, instead of 'LIMIT 20' i would like the limit to be only posts that were made on the current day. How do i accomplish this?
If i were to add another field to my database like the current date, November 22, 2008, that would then be attributed to each row that was created on that day. Would i be able to set my LIMIT function to something like this?
Thus, allowing me to call only the rows that were posted on November 22, 2008?
Thank you.
Code: Select all
mysql_connect("server","","");
mysql_select_db("");
$query ="SELECT type, poster, during, time";
$query.=" FROM ws ORDER BY time DESC LIMIT 20";
$result=mysql_query($query);
while (list($type,$poster,$during,$time) =
mysql_fetch_row($result)) {
If i were to add another field to my database like the current date, November 22, 2008, that would then be attributed to each row that was created on that day. Would i be able to set my LIMIT function to something like this?
Code: Select all
<?php
$today = date("l, F j, Y");
$query.=" FROM ws ORDER BY time DESC LIMIT $today";
?>
Thank you.