At 05.04.2002 12:31, you wrote: > >Jason, > >This is for an events calendar, I want all the dates form the db but when I >am generating the individual days for the calendar I need to know whether >there is an event for that day, hence pulling out all the dates from the db. >As I am looping through all the days in a month to dynamically create the >calendar, I do not want to loop through the entire recordset to look for a >date for that day in each iteration. Does your method find any row in the >recordset with a given date?
As I understand your problem, I would suggest, that you just select the days in the month, where there are events f.e. select count(ref#) from DB where date 'inside your scope' and events 'are there events' this gives you the number of lines. If there are any, you could ask more detailed, using the informations stored. If there are no events, make the calendar as normal. Thats also a good explanation for the column ref# (autoincrement, unique) Even you only have to deal with one select, and can order your result, so that it makes you no pain showing them >I am at present exploring the possibility of creating individual arrays for >each row in the recordset using the date as the name of the array, then >testing to see if it exists. That way I can check for the existence of a >given date at any point in my code and reference the associated values >without looping through the recordset each time. My code is as follows... > >while ($row = mysql_fetch_assoc($events)) { > $a = "date_" . $row["event_date"]; > $$a = array($row["event_id"], $row["event_title"]); >} Here the select could be Assuming you have the DB´s 'event_ref ' where 'event date' and 'event reference number' put in and 'event_content' where other useful informations are stored selct a.event_title, from event_ref a, event_content b where b.ref = a.ref and a.date='2002-04-15' No dealing with arrays and var_vars, just straight sql. HTH Oliver >if ($date_2002-04-15) { do_something(); } > >Any comments will be greatfully received. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php