Jump to content

Show Image for 2 days


Sparchy

Recommended Posts

I was wondering how i could have an image show for say like 2 days.. like i play at a Virtual Navy site and i help with the web site and we have new bounties each month and i would like to have a image that says New so people know there is new bounties posted.. so how can i create and If Statment to check the date issued and check to see if 2 days has past or not

 

Thank you

Sparchy

Link to comment
https://forums.phpfreaks.com/topic/200108-show-image-for-2-days/
Share on other sites

well here is my code i have now

 

$result = mysql_query('SELECT * FROM bounties where status = 'Active' AND $start_date > $today - 2 days'); 
		if ($result) { 
		echo '<img src="../svn/images/new.gif">'; 
		}else{ 
		echo ' '; 
		}

 

but im getting parse error in the mysql query line im not sure what im doing wrong

 

Thank you

Sparchy

 

following problem in your query :-

1. String is not escaped properly

2. To calculate date difference you have to use "date_diff" function.

 

for `column_name` you have to give tables field name

 

 

$result = mysql_query("SELECT * FROM bounties where status = 'Active' AND  
`column_name` <= date_diff(now(), interval 2 days)");

if ($result) { 			
echo '<img src="../svn/images/new.gif">'; 
}else{echo ' '; 			
}

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.