Web Design Forum: SQL & Date Range(s) - Web Design Forum

Jump to content

WDF
WDF Premium Memberships Reseller Hosting
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

SQL & Date Range(s) Rate Topic: -----

#1 User is offline   Northern Star 

  • Forum Newcomer
  • Pip
  • Group: Members
  • Posts: 61
  • Joined: 13-October 06
  • Reputation: 0
  • Location:Cheshire, UK
  • Experience:Advanced
  • Area of Expertise:Designer/Coder

  Posted 15 October 2006 - 07:18 PM

OK, I need some help with this one. I hate admitting defeat but I'm getting frustrated!

I've got a table called 'Events' with these fields...

eID
eName
eStartDate
eEndDate

An example entry would be...

1
'Course Open Day'
12-Nov-2006
14-Nov-2006

What I want to be able to do is search the table and select any records where a given date falls between the the startDate and endDate.

So, if I searched with '13-Nov-2006' i'd get 'Course Open Day'.

Hope I've made myself clear!

Thanks, Andy.
0

#2 User is offline   Ben 

  • Web Designer Forum Admin
  • View gallery
  • Group: Root Admin
  • Posts: 2,839
  • Joined: 24-August 06
  • Reputation: 100
  • Gender:Male
  • Location:Essex, UK
  • Experience:Intermediate
  • Area of Expertise:Web Designer

Posted 15 October 2006 - 07:47 PM

<?php

$query = "SELECT eID, eName, eStartDate, eEndDate FROM events";
$result = mysql_query($query);

while($row = mysql_fetch_assoc($result))
{
echo "Name :{$row['eName']} <p />" .
"Start Date : {$row['eStartDate']} <p />" .
"End Date : {$row['eEndDate']} <p />";
}

?>
0

#3 User is offline   Northern Star 

  • Forum Newcomer
  • Pip
  • Group: Members
  • Posts: 61
  • Joined: 13-October 06
  • Reputation: 0
  • Location:Cheshire, UK
  • Experience:Advanced
  • Area of Expertise:Designer/Coder

Posted 15 October 2006 - 08:43 PM

That will just return all the records in the table? :rolleyes:
0

#4 User is offline   Ben 

  • Web Designer Forum Admin
  • View gallery
  • Group: Root Admin
  • Posts: 2,839
  • Joined: 24-August 06
  • Reputation: 100
  • Gender:Male
  • Location:Essex, UK
  • Experience:Intermediate
  • Area of Expertise:Web Designer

Posted 15 October 2006 - 08:55 PM

Ah Gotcha!

Sorry

Ermmmm, gotcha, ok, does this link help at all?

http://www.help.thinkhost.com/web-developm...-forms_359.html

Ben
0

#5 User is offline   Northern Star 

  • Forum Newcomer
  • Pip
  • Group: Members
  • Posts: 61
  • Joined: 13-October 06
  • Reputation: 0
  • Location:Cheshire, UK
  • Experience:Advanced
  • Area of Expertise:Designer/Coder

Posted 16 October 2006 - 07:49 AM

Not really :blink: , but thanks for the link - looks like a good reference page!

I might have to give in and do it another way :(
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users