PDA

View Full Version : Help with a date issue in PHP



skyler
January 5th, 2007, 04:41 PM
Okay. I have a showlister. Its simple enough, so Im not going to go into how it runs because it runs perfect.

My issue is when the event gets removed from the database. This took me a long time to figure out such a simple solution, but there is one error. It deletes all event prior to today and including today's events. I want todays events to stick around until the day is over.

:red:


Here is my code:


$today = date('Y-m-d');
$removeShows="Delete from shows where showDate between '1950-01-10' and '".$today."'";
$removeResult = mysql_query($removeShows) or die (mysql_error());

Sniper Jo
January 5th, 2007, 05:09 PM
Well, thats because your using BETWEEN therefor .. Everything in between $today and 1950-01-10 is going to get deleted.. You should delete the date by using the PRIMARY KEY.. ie its ID..

bwh2
January 5th, 2007, 06:10 PM
yeah, you should have an ID field as your primary key. then just delete based on ID.