Jump to content


Photo

displaying results from a certain date till now


  • Please log in to reply
3 replies to this topic

#1 digitalgod

digitalgod
  • Members
  • PipPipPip
  • Advanced Member
  • 374 posts

Posted 09 July 2006 - 07:32 AM

hey guys,

I was wondering how can I display something from a database from a certain date till now.

#2 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 09 July 2006 - 10:52 AM

<?
$database_date="1/1/06"; //just add the $whatever['data_basedate_here'];

$date_know=date("d/m/y");

if(!$database_date-$date_know){

echo"hello";

}else{

echo"sorry wrong date";

}
?>
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#3 ShogunWarrior

ShogunWarrior
  • Members
  • PipPipPip
  • Advanced Member
  • 528 posts
  • LocationIreland

Posted 09 July 2006 - 01:39 PM

I'm going to take your question as being that you want to display only rows that have a dated from x until now.

To do this I'd need to know how the date is formatted.
<a href="http://www.daviddora...nmedia.com/">My New Site/Blog</a> | <a href="http://www.daviddora...m/check/">Check your page for broken links/images/scripts</a>

Zend Certified Engineer
Follow me on Twitter: http://twitter.com/davidd

#4 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 09 July 2006 - 02:32 PM

$timestamp = 'some_unix_timestamp_here'; // replace it with a timestamp
$query = mysql_query("SELECT * FROM some_table WHERE timestamp<=".time()." AND timestamp>={$timestamp}");
if(mysql_num_rows($query) <= 0)
{
	echo "No things from ".date('r')." untill now";
}
else {
	while($row = mysql_fetch_assoc($query));
	{
		// do stuff
	}
}

In case you have it in a database where the date is stored as a UNIX timestamp, which would be the prefered way to do it.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users