Forum Moderators: coopster

Message Too Old, No Replies

Help with displaying todays dates

         

gin0115

9:19 am on Jul 12, 2005 (gmt 0)

10+ Year Member



Dont suppose any one could give a PHP newbie a hand could they?

I have made a small php gig guide but am finding it hard to find out how to run a query based on todays date

I have the day, month & year stored in seperate rows. can i over come this using php or wouild i have to use Javascript?

my query so far is

$query = "SELECT id, venue, band1, band2, band3, band4, band5, cost, time FROM guests WHERE day='10' ORDER BY day ASC";

also is there any way to set a second "WHERE" variable to the query?

vincevincevince

9:22 am on Jul 12, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



WHERE day='10' AND month='2' AND year = '2005'

ReveL

3:18 pm on Jul 12, 2005 (gmt 0)

10+ Year Member



make it dynamic:

$query = "SELECT id, venue, band1, band2, band3, band4, band5, cost, time FROM guests WHERE day=DAYOFMONTH(NOW()) AND month=MONTH(NOW()) AND year=YEAR(NOW()) ORDER BY day ASC";

it will always pick todays date.

vincevincevince

5:27 pm on Jul 12, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If it were me I'd have stored it as a timestamp in the first place...

mogenshoj

5:38 pm on Jul 12, 2005 (gmt 0)

10+ Year Member



I would use time() for getting dates.

You can always get todays date with:
$today = mktime(0, 0, 0, date("n"), date("j") , date("Y"));

You need to insert it this way too.

It would be easier if you later choose to select data from the last xx days.