Jump to content

Help with this sql statement


rondog

Recommended Posts

I use this to make sure no two date ranges conflict since their can only be one featured event:

$sql = mysql_query("SELECT * FROM de_featured_event WHERE '$startdate' BETWEEN start_date AND end_date OR '$enddate' BETWEEN start_date AND end_date") or die(mysql_error());

 

That works fine. What isn't working for me is when I am editing an event, I run the same query except I say where id != $_GET[id]:

$sql = mysql_query("SELECT * FROM de_featured_event WHERE id != '".$_GET['id']."' AND '$startdate' BETWEEN start_date AND end_date OR '$enddate' BETWEEN start_date AND end_date") or die(mysql_error());

 

Basically I dont want it to select the date that I am editing. No matter what I do it always selects one row. That row being the one that is open hence the id != $_GET[id].

 

 

Any ideas?

Link to comment
https://forums.phpfreaks.com/topic/201708-help-with-this-sql-statement/
Share on other sites

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.