i have an upload script which takes a timestamp when an advert is uploaded, i want to create a script that will echo the last 10 uploads according to the timestamp.
i have no idea how to do this, any help much appreciated!!
<?php
$now = date("Y-m-d H:i:s");
echo $now;
$sql = "SELECT * FROM people WHERE posttime < $now LIMIT 0, 10";
$q = $conn->prepare($sql) or die("failed!");
// Bind the params to the placeholders
$q->execute();
?>
the time stamp is as follows:
2012-10-05 14:40:21
Better is use MySQL condition:
But in your case
posttimealways lower than current, I think 🙂 In this case I think right query is:But if your compare time not always current time, than add condition: