Jump to content


Photo

php/mysql Date verification


  • Please log in to reply
2 replies to this topic

#1 pugs1501

pugs1501
  • Members
  • PipPip
  • Member
  • 15 posts

Posted 05 May 2006 - 08:08 AM

I was wondering if any one could help me figure out how to setup and seck to see if a start and end date which would be stored in the mysql database have been met or not. If the start date has been met and the end date has not i want it to display the data in the table if the start date has not been met or the end date has been met then the data should disapear off the screen then.

#2 onepixel

onepixel
  • Members
  • PipPip
  • Member
  • 18 posts

Posted 05 May 2006 - 05:23 PM

[!--quoteo(post=371467:date=May 5 2006, 03:08 AM:name=pugs1501)--][div class=\'quotetop\']QUOTE(pugs1501 @ May 5 2006, 03:08 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
I was wondering if any one could help me figure out how to setup and seck to see if a start and end date which would be stored in the mysql database have been met or not. If the start date has been met and the end date has not i want it to display the data in the table if the start date has not been met or the end date has been met then the data should disapear off the screen then.
[/quote]


If I understand your question the data will be displayed only if the $current_date is between your $start_date and $end_date?

The date in mysql database will have the format Year-Month-Day
First:
$current_date=date("Y-m-d");

Let's assume the columns for the start date and end date in your database table are: start_date and end_date. Your query will be something like:

$query="Select field1, field2,... from Tablename where startdate<='".$currentdate."' and enddate>='".$current_date."'";

You can then extract the results as you will.

<a href="http://www.saheltech.com">PHP Programming - WordPress Blog Customization</a>

#3 pugs1501

pugs1501
  • Members
  • PipPip
  • Member
  • 15 posts

Posted 10 May 2006 - 05:56 PM

thank you for your very quick response and all is working just fine but i was just wondering if you any one could help me write a if statement that will only show a title if their is results in the date statement.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users