General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

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 January 5th, 2004, 12:38 PM
CHornJr's Avatar
CHornJr CHornJr is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Location: New York City
Posts: 236 CHornJr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 1 h 50 m 36 sec
Reputation Power: 16
Send a message via AIM to CHornJr Send a message via MSN to CHornJr Send a message via Yahoo to CHornJr
Angry Calendar Page not properly showing data (date column and/or between suspected fellon

My calendar page is suppose to list the events for each month, ie
January
1 - Event name

However it is only showing me the month. My guess is that it is not showing the the other information because of my query. I have a date column and I am using the between function in my where clause. First time I am using date column type and between function. However I have gone over the code, particulary the query and can't fiqure out what is wrong. Any help would be greatly appreciated.

Code in attached file
Attached Files
File Type: zip chornjr_error.zip (1.3 KB, 589 views)
__________________
CHornJr
"One day I'll know what I am doing"
My Blog
Suanhacky Lodge #49
Rebel Squadrons

Reply With Quote
  #2  
Old January 5th, 2004, 12:54 PM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
Send a message via ICQ to dhouston
Do you know that it's copacetic to use BETWEEN with dates? For kicks, expand your query to use >= and <= to limit the range. If that works, then it's probably a matter of BETWEEN not evaluating the date expression correctly.

Reply With Quote
  #3  
Old January 5th, 2004, 07:28 PM
Mike_r Mike_r is offline
ExoCrew
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 68 Mike_r User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 15
There is nothing wrong with using BETWEEN as long as you use it correctly.

mysql_query("SELECT * FROM calendar WHERE start_date BETWEEN '$currentdate' AND 'endofmonth'

change that to

mysql_query("SELECT * FROM calendar WHERE start_date BETWEEN $currentdate AND $endofmonth

And it should work then.
__________________
ExoHelpDesk
ExoCrew Free Services

Reply With Quote
  #4  
Old January 5th, 2004, 11:57 PM
CHornJr's Avatar
CHornJr CHornJr is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Location: New York City
Posts: 236 CHornJr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 1 h 50 m 36 sec
Reputation Power: 16
Send a message via AIM to CHornJr Send a message via MSN to CHornJr Send a message via Yahoo to CHornJr
Cool

I found out what was wrong. I echoed out currentdate and endofmonth variables again and I then remebered after viewing it that getdate() months come back as 1 not 01 (in the case of January). So I added a switch statement that has Case 10,11, 12 keep as is, if month equal to 1-9 make month= 01-09

PHP Code:
switch($month)
{
case 
10:
case 
11:
case 
12:
$currentmonth $year.'-'.$month.'-00';
$endofmonth $year.'-'.$month.'-31';
break 
1;
default:
$currentmonth $year.'-0'.$month.'-00';
$endofmonth $year.'-0'.$month.'-31';



I havn't finished fully testing all of it yet, but so far seems to be working ok now

Quote:
There is nothing wrong with using BETWEEN as long as you use it correctly.

mysql_query("SELECT * FROM calendar WHERE start_date BETWEEN '$currentdate' AND 'endofmonth'

change that to

mysql_query("SELECT * FROM calendar WHERE start_date BETWEEN $currentdate AND $endofmonth

And it should work then.


if you put php variables inside a select statement with out them being surrounded by single quotes you WILL get a parse error because MySQL thinks they are a string instead of variables. (Look, I actually knew something ahead of time, WOW )

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > Calendar Page not properly showing data (date column and/or between suspected fellon


Developer Shed Advertisers and Affiliates


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 | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap