Sparchy Posted April 29, 2010 Share Posted April 29, 2010 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 More sharing options...
litebearer Posted April 29, 2010 Share Posted April 29, 2010 just a thought (Psuedo code) image table id image_name image_date select image_name from image_table where image_date> current_date - 2 days if result display image else no display Link to comment https://forums.phpfreaks.com/topic/200108-show-image-for-2-days/#findComment-1050282 Share on other sites More sharing options...
teamatomic Posted April 29, 2010 Share Posted April 29, 2010 get the day of the month: if($day<3){do the image} that would show the image the first and second of each month. HTH Teamatomic Link to comment https://forums.phpfreaks.com/topic/200108-show-image-for-2-days/#findComment-1050303 Share on other sites More sharing options...
Sparchy Posted April 29, 2010 Author Share Posted April 29, 2010 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 Link to comment https://forums.phpfreaks.com/topic/200108-show-image-for-2-days/#findComment-1050306 Share on other sites More sharing options...
anups Posted April 29, 2010 Share Posted April 29, 2010 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 ' '; } Link to comment https://forums.phpfreaks.com/topic/200108-show-image-for-2-days/#findComment-1050327 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.