i made myself a event calendar which works great except for one minor detail which i would like to fix. which is if 1 date lets say today's date 09/10/2011 has 3 events on it it only shows the most recent one posted.. i want it to post all 3 events..
I'll be honest, I'm being lazy and just posting what I think will work. I haven't tested this or done much more than look over the code you posted, but this seems like something that ought to fix the problem:
All I did was add that "." right before the "=" character to append to the $link variable's value for each trip through the loop. Without that, you are overwriting the existing value on each pass through, which means you are only getting the last value from the loop.
If that doesn't work let me know and I'll get off of my butt and take a closer look.
Thanks for the reply but that didn't help it just on some of the numbers (mainly event dates) it showed the day before and the day of the event in one table row lol but it was something to try lol..
sorry i don't know where my mind is lol.. but if i move the bracket down it will only output just the event dates and not the calendar itself. i already tried that before a well lol..
msleim is entirely correct. Just now, what you're doing is getting a resultset of events for a date, then reassigning your variables $dates etc. inside the while loop, so that you'll only get 1 result from that while loop - the last row found from your query. Your logic isn't all there.
What you need to do, is change it. You need to find the date (already doing that) then run the query for events in that date (already doing that) THEN you need to loop through the rows using a while loop (already looping through the rows) and output the results in your desired format INSIDE the while loop. Either that, or assign results inside the while loop to an array, which isn't always the best answer and probably not the best for this method. Count rows is not needed here, and should only be used if you're wanting to output the number of events.
i understand what you guys are saying but the way my script is set up if i put it in the while loop it will only output the event dates but not the whole calendar. i been down this road once trying to figure out how to get it to do that but its over my head lol.. if you run my script and look and edit yourself you will find out what im talking about.
here is the sql if you want to test it out
Code:
CREATE TABLE `event` (
`id` int(25) NOT NULL default '0',
`dates` date NOT NULL default '0000-00-00',
`events` varchar(255) collate latin1_general_ci NOT NULL default '',
`event_des` text collate latin1_general_ci NOT NULL,
`time` varchar(25) collate latin1_general_ci NOT NULL default '',
`username` varchar(255) collate latin1_general_ci NOT NULL default '',
`filter` varchar(255) collate latin1_general_ci NOT NULL default '',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;
What I'm telling you to do is redo it with a thought about logic in your code design. Your while loop is definitely set up wrong, it is definitely giving you problems and needs changed.
I'm old school.
Comments consume bytes of memory.
Although good to have, we were taught to compress code as much as possible.
No white space, no comments. I guess it's not 1979 anymore.
haha wrong thread msleim . But aye, I argued that in school but got a stern 'I NEED TO BE ABLE TO READ WHAT'S GOING ON' from my teacher, who didn't actually know the language haha.