PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old October 5th, 2004, 11:42 AM
Scot Scot is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 29 Scot User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 m 17 sec
Reputation Power: 0
Smile Whats wrong with this snippet

Good Day Yall!

I am looking for a insightful eye to look at the following snippet and tell me what I am doing wrong! I am using PHP 4.3 and MySQL and the following snippet is supposed to allow the user to enter two dates and run a query which will return all the records with dates equal to or between the two dates entered. Unfortunately, all it does is return the record set for only the two dates specifically entered. For example if I enter 10/01/04 and 10/15/04 it returns all the records for only those two days and none of the days in between. I want it to return the record set for the dates entered and all the dates between. Records with dates of 10/01/04 through 10/15/04. I have tried <= and >= but that doesn't work. I know the answer is probably incredibly simple but I am rather dumb and stuck to boot! Any help or suggestions appreciated. Here is the query I am using
$result = mysql_query( "SELECT * FROM ttime where ((SNUM = '".$_SESSION['SNUM']."') and ".$TIDATE." like '%".$TIDATEA."%') or ((SNUM = '".$_SESSION['SNUM']."') and ".$TIDATE." like '%".$TIDATEB."%') ORDER BY TIDATE ASC")
or die("SELECT Error: ".mysql_error());

Thanks
Have a Great Day!

Reply With Quote
  #2  
Old October 8th, 2004, 10:57 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
Have you considered using the clause BETWEEN?

For example:
Code:
SELECT * 
FROM ttime
WHERE SNUM BETWEEN '2004-10-01' AND '2004-10-31'

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > Whats wrong with this snippet


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT