lunac Posted July 25, 2008 Share Posted July 25, 2008 Hi, I'm trying to pass some values into a calendar I'm making. I have the calendar itself working fine, now I'm trying to put the event titles on to it. But I'm have problems getting items for a particular date. My date field is a timestamp in mysql. Any help would be appreciated. here's my code: $e = mysqlSelect($_tables['squirrel_post'], "post_slug, title, date", "WHERE date = $date"); if I take the date out -- it works, but then I'm getting all the post rather than just the post of that day. Also, I know that it's passing the date as 2008-7-6 -- which isn't right either. by the way.. here's the code for my mysqlSelect function --- which is complete function (lol) function mysqlSelect($from, $what="*", $conditions=""){ $query = "SELECT $what from $from $conditions"; $r = lib_executeQuery($query) or die(mysql_error()); return $r; } function lib_executeQuery($query,$dbLink=""){ // Execute an SQL query passed to this function if($dbLink){ $link = $dbLink; } else { $link = lib_databaseConnect(); } $dbResult = mysql_query($query, $link) or die ("Database Class: MySQL Error: " . mysql_error() ); return $dbResult; } Link to comment https://forums.phpfreaks.com/topic/116515-need-help-finding-item-by-date-mysql/ Share on other sites More sharing options...
dezkit Posted July 25, 2008 Share Posted July 25, 2008 wats ur $date variable set2 Link to comment https://forums.phpfreaks.com/topic/116515-need-help-finding-item-by-date-mysql/#findComment-599106 Share on other sites More sharing options...
lunac Posted July 25, 2008 Author Share Posted July 25, 2008 wats ur $date variable set2 sorry -- just updated the post above. Link to comment https://forums.phpfreaks.com/topic/116515-need-help-finding-item-by-date-mysql/#findComment-599109 Share on other sites More sharing options...
lunac Posted July 25, 2008 Author Share Posted July 25, 2008 HAHAHA That was exactly the problem -- the date was entering into the query wrong, so I caught it on the front end. SOLUTION: $gm = strlen($month); $month =($gm == 1)? "0" . $month : $month; $currentDay =($gm == 1)? "0" . $currentDay : $currentDay; $date = "$year-$month-$currentDay"; $e = mysqlSelect($_tables['squirrel_post'], "*", "WHERE date= '" . $date . "'"); Link to comment https://forums.phpfreaks.com/topic/116515-need-help-finding-item-by-date-mysql/#findComment-599115 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.