SELECT something
, anything
, just_not_the_dreaded_evil_select_star
FROM texts
WHERE content IS NOT NULL
AND messagesent = 0
AND datereceived BETWEEN CURRENT_TIMESTAMP - INTERVAL 5 MINUTE
AND CURRENT_TIMESTAMP
SELECT * FROM `texts` WHERE `content` IS NOT NULL AND `messagesent` = 0 LIMIT 5
to pull in the sms to display.
i though by doing
UPDATE `texts` SET `messagesent` = 1 WHERE id = ".$row[0]." AND datereceived BETWEEN CURRENT_TIMESTAMP - INTERVAL 20 MINUTE AND CURRENT_TIMESTAMP
after the contents had been displayed it would then update any id with the timestamp of now and between 20 mins old and it appears to just update them after around 5 and i have checked the code to confirm it’s set to 20.
it appears to of done it all weirdly as i texted the number about 1 min ago and checked the database and it’s showing already as sent.
$result = mysql_query('SELECT * FROM `texts` WHERE `messagesent` = 0'); // Is there any texts to display? if not adverts to show.
if ($result) {
if (mysql_num_rows($result) == 0) {
include ('ads.php');
}
else {
$sms = mysql_query("SELECT * FROM `texts` WHERE `content` IS NOT NULL AND `messagesent` = 0 LIMIT 5"); //Grab 5 messages to display
while ($row = mysql_fetch_array($sms)) {
echo (' '.$row['content'].' ');
mysql_query("UPDATE `texts` SET `messagesent` = 1 WHERE id = ".$row[0]." AND datereceived BETWEEN CURRENT_TIMESTAMP - INTERVAL 20 MINUTE AND CURRENT_TIMESTAMP") //updates 'messagesent' to show it has been sent out.
or die(mysql_error());
}
}
}