I have a SELECT WHERE statement that I am having issues with. Below is the code that is causing the problem. Granted, probably not the cleanest code (still learning), but for the most part it works. $result3 = mysql_query('SELECT date FROM ongoing ORDER BY ID DESC LIMIT 1'); $datadate = mysql_fetch_row($result3); $datadate = $datadate[0]; $result14 = mysql_query('SELECT MAX(outdoortempF) FROM ongoing WHERE date="$datadate"'); $maxtemp = mysql_fetch_row($result14); $maxtemp = $maxtemp[0]; PHP: The first section works just as expected (returns the DATE (YYYY-MM-DD) from the date field in the database). The second section is where I am having trouble. I can't seem to get the date="$datadate" part to work. The code simply returns nothing. On the other hand, if I type in the date so it reads date="2007-12-10", the code works perfectly. In addition, if I try echo "$datadate" it returns 2007-12-10. How can I get it to pull "outsidetempF" data only from rows where the date = today? Thanks!
This might help $result14 = mysql_query('SELECT MAX(outdoortempF) FROM ongoing WHERE date="'.$datadate.'"'); $maxtemp = mysql_fetch_row($result14); $maxtemp = $maxtemp[0]; If you have trouble with queires echo it out. echo 'SELECT MAX(outdoortempF) FROM ongoing WHERE date="'.$datadate.'"'; and see if it comes out as expected with all the varialbles.