Jump to content

Archived

This topic is now archived and is closed to further replies.

pugs1501

php/mysql Date verification

Recommended Posts

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.

Share this post


Link to post
Share on other sites
[!--quoteo(post=371467:date=May 5 2006, 03:08 AM:name=pugs1501)--][div class=\'quotetop\']QUOTE(pugs1501 @ May 5 2006, 03:08 AM) [snapback]371467[/snapback][/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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

×

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.