This would be an example of database table:

PHP script should limit query result between NOW and time before 30 seconds
To be clear:
In current time is 2012-03-23 03:28:00 and database is as descibed in example, resoult should be: “guest”
This is a part of PHP script.
<?php
$con = mysql_connect("localhost", "user", "pass");
if (!$con) {
die('Could not connect: '.mysql_error());
}
mysql_select_db("db", $con);
$result = mysql_query('SELECT * FROM table LIMIT BY ...???...... ');
while ($row = mysql_fetch_array($result)){
echo $row['username'];
}
mysql_close($con);
?>
You don’t want a
LIMIT, you want aWHEREIn SQL, a
LIMITclause executes the whole query, and then only takes a certain “range” of consecutive rows. You can say “The first 50”, or “From 20 to 30”.A
WHEREclause limits the query on certain criteria, such as field contents. That is what you want here.