spillage Posted May 7, 2008 Share Posted May 7, 2008 Sorry After spending hours looking I think I need to post this question. My code is: $result = mysql_query("SELECT * FROM email WHERE printer LIKE '%$printer%' WHERE time BETWEEN '$date' '$todate'"); if ($cust=='all') { while($row = mysql_fetch_array($result)) { echo $row['printer']." | ".$row['cust']," | ".$row['friend']; echo "</br>"; } } else if ($cust=='cust') { while($row = mysql_fetch_array($result)) {echo $row['printer']." | ".$row['cust']," | "; echo "</br>"; } } else if ($cust=='friend') { while($row = mysql_fetch_array($result)) { echo $row['printer']." | ".$row['friend']," | "; echo "</br>"; } } This will not run at all. If I print out the values of $data and $todate they both show yy-mm-dd. If I remove the time query then everything runs fine. Really hit a brickwall. Do not that I have been cutting and adding to the code in the query so whats shown may have a couple of typos in. Cheers, Spill. Quote Link to comment https://forums.phpfreaks.com/topic/104550-solved-another-mind-numbing-question-on-query-dates-between/ Share on other sites More sharing options...
fenway Posted May 7, 2008 Share Posted May 7, 2008 You mean: $result = mysql_query("SELECT * FROM email WHERE printer LIKE '%$printer%' AND time BETWEEN '$date' AND '$todate'"); The "AND" was missing for BETWEEN, and you had two where clauses. Quote Link to comment https://forums.phpfreaks.com/topic/104550-solved-another-mind-numbing-question-on-query-dates-between/#findComment-535160 Share on other sites More sharing options...
spillage Posted May 7, 2008 Author Share Posted May 7, 2008 cheers for the reply fenway I am sure I had tried this and got an error within the if code. BUT as I am find in this world of code its all now working. So thanks again fenway and Im off to have a couple beers. Spill Quote Link to comment https://forums.phpfreaks.com/topic/104550-solved-another-mind-numbing-question-on-query-dates-between/#findComment-535177 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.