Jump to content

bigger than operator in SQL. passing variables to SQL.


daydreamer

Recommended Posts

			$time=time();
			$onedayago=$time-86400; //86400 seconds in 24 hrs, 5 texts in any one 24 hr period
			$checkpass = mysql_query("SELECT * FROM texts
						   WHERE id='{$_SESSION['id']}'
						   AND date >'$onedayago' ") 

 

I am trying to select all rows that have a date column from the last 24hrs, the date column is in mktime format.

 

All I need is a count. Is this the way to do it?

Thanks.

$result = mysql_query("SELECT COUNT(id) AS `count` FROM texts WHERE id='{$_SESSION['id']}' AND date >'$onedayago' ");
$result = mysql_fetch_array($result);
echo $result[0]['count'];

 

fixed it a little and somefield could be any field that is in the table.

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.