Hi all. I am building an online events registry and have mapped out all the
dates between Oct 1 2006 and Dec 31 2030, stored in the database as
timestamps incremented by 86400 to give daily slots. I have output the
values using the php date function and all is well. Users can enter either
one-off or regular events, and I am using a mapping table to tie events to
dates as they comprise a many-to-many relationship.

I am struggling with some date conversions, however. When a user enters a
single event for example, the data is entered into the events table, the
inserted id captured, and then the system will look for the relevant record
in the dates table, and eventually enter the event id and date id into the
mapping table for later joins during the search process.

To do this, I call:

$date_string =
mktime(0,0,0,$_SESSION['month],$_SESSION['day'],$_SESSION['year'])

to assemble a timestamp from the supplied user data, and now I need to look
for the matching date in the dates table. My problem is in converting
between UNIX and mySQL timestamp values. My first attempt to match used this
(query extract):

"SELECT id FROM dates WHERE FROM_UNIXTIME($date_string) = date"

then

"SELECT id FROM dates WHERE UNIX_TIMESTAMP(date) = $date_string"

neither is working. Am I making some fundamental error here or missing
something? Any help appreciated!

--
http://www.web-buddha.co.uk
http://www.projectkarma.co.uk

Reply via email to