colmustard Posted July 19, 2010 Share Posted July 19, 2010 Hi, I am able to fetch and display the data from the table, however I need a system where I can pick and choose which data to display. For example if a certain date is specified the loop needs to only pull out the data with the task_log_date that corresponds. Currently it just loops through everything in the database, this is great but I only want to pull out data that is related to the current date. Here is a snippet of my code. Any help is greatly appreciated! $today = date("m/d/y"); $thistime=0; $totaltime=0; $query = "SELECT * FROM task_log WHERE `task_log_creator` = ".$creator." AND `task_log_date` >= '".$today."' ORDER BY task_log_date"; $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error()); // if records present if (mysql_num_rows($result) > 0) { // iterate through resultset // print title with links to go to that Item while($row = mysql_fetch_object($result)) { echo '<tr>'; echo '<td>'. $row->task_log_id . '</td>'; echo '<td>'. $row->task_log_task . '</td>'; echo '<td>'. $row->task_log_name . '</td>'; $description = $row->task_log_description; echo '<td>'. nl2br($description) . '</td>'; echo '<td>'. $row->task_log_hours . '</td>'; echo '<td>'. $row->task_log_date . '</td>'; echo '<td>'. $row->task_log_related_url . '</td>'; echo '</tr> '; $thistime = $row->task_log_hours; $totaltime = $totaltime + $thistime; } echo '<tr>'; echo '<td> </td><td> </td><td> </td><td> </td>'; echo '<td class="total">'. $totaltime .'</td>'; echo '<td> </td><td> </td>'; echo '</tr>'; } Quote Link to comment Share on other sites More sharing options...
msaz87 Posted July 19, 2010 Share Posted July 19, 2010 Not exactly sure, but my assumption is it's how you're formatting your date that it's confusing the WHERE clause. Are you storing the dates in the table in the m/d/y format? I think the general way to do it is yyyy-mm-dd and MySQL might not know how to process it otherwise with the slashes in there. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.