Really I am a PHP beginner, I am working on this code and I need help, kinda stuck.
I have a database with 3 fields(id, date and venue). This is simply what I want to do;
I want my script to go into the database fetch the date and compare it with a declared date(todays date) and if both days are equal, it should echo out the venue that corresponds to the date taken from Mysql.


First you must have a valid date field in your table structure.

SELECT venue FROM tablename WHERE date_column = curdate()
commented: He is great. +1

I already tried the code below and it didn't work.

// DB info here
$curDate = date("Y-m-d");
$query = "Select venue from programOutline where date = $curDate";
$result = mysql_query($query);   
    while ($row = mysql_fetch_array($result)){
        echo "Today's program is at " .$row['venue'];

Anyway thanks for replying so quick.

In what form is the date stored, as a date object or in some text form, comparing DMY d - m y y-MD makes a lot of difference, it may be impoosible to match different date formats

edit, impoosible ?? ha ha

As far as I know, my variable $curDate corresponds to that of mysql. I am using the DATE data type in mysql which is of format YYYY-mm-dd. When I even convert it to time with the strtotime() function, it still doesn't work.
ie strtotime($curDate) == strtotime($row doesn't work.


Your doing it incorrectly. ;)

This should work:

$query = "Select venue from programOutline where `date` = '$curDate'";

If you're only interested in today, this works too:

$query = "Select venue from programOutline where `date` = CURDATE()";

Please show me thy ways.

Thanks to all of u guys for helping me out. @pritaeas, thanks for the code, it worked.

Yeah I know I closed this thread but something came up, I am now able to compare both dates but I want to evaluate it so that if there is no activity for the day, I will be able to echo some kinda msg. I am finding it difficult to construct my conditional statement. Thanx

just a thought not verified code

// DB info here
$curDate = date("Y-m-d");
$query = "Select venue from programOutline where date = $curDate";
$result = mysql_query($query);   
 if(!$result) {echo 'No program today';}
 while ($row = mysql_fetch_array($result)){ echo "Today's program is at " .$row ['venue']; }

Thanks, anyway, I got around that and I ended up with this,

if($row = mysql_fetch_array($result)){
echo $row['venue'];
}while($row = mysql_fetch_array($result));
echo "No Available Program";
//I hope this helps someone