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?

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"]);
}

if ($date_2002-04-15) { do_something(); }

Any comments will be greatfully received.

Phil.

> -----Original Message-----
> From: Jason Wong [mailto:[EMAIL PROTECTED]]
> Sent: 05 April 2002 11:31
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] mysql_fetch_array()
>
>
> On Friday 05 April 2002 18:21, you wrote:
> > Hi All,
> >
> > I am new to PHP and am having a bit of trouble. I have a
> recordset using...
> >
> > $events = mysql_fetch_array($recordset);
> >
> > this drags in 3 columns from my table...
> >
> > event_id, event_title, event_date
> >
> > I want to search the recordset for a given date, if found I
> want to be able
> > to reference event_id & event_title from the row. I am using PHP 4.01.
>
> Shouldn't you be doing your searching and selecting from within
> your mysql
> query?
>
> But if you insist on doing it in PHP then:
>
>
> if ($events['event_date'] == whatever) {
>   do_something();
> }
>
>
>
> --
> Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
>
> /*
> You will engage in a profitable business activity.
> */
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to