Wickham Posted December 1, 2009 Report Share Posted December 1, 2009 (edited) I have a booking form with a MySQL database and I have a web page where the current bookings are displayed. At present this code makes the printed table show all entries after yesterday: $q = "SELECT * FROM villagehall WHERE date >= '$today' ORDER BY date, starttime, endtime"; and I have also tested this one which shows all entries that are not cancelled:- $q = "SELECT * FROM villagehall WHERE book != '$cancel' ORDER BY date, starttime, endtime"; and both work individually when followed by $result = mysql_query($q) or die ("error!"); while ($row = mysql_fetch_array($result)){ echo table..........} but how do I combine them into one SELECT? I want to keep the cancelled entries in the database. Edited December 1, 2009 by Wickham Quote Link to comment Share on other sites More sharing options...
Wickham Posted December 1, 2009 Author Report Share Posted December 1, 2009 After much Googling and experimenting I found that I basically just had to add the word AND into the code so the individual SELECT queries:- $q = "SELECT * FROM villagehall WHERE date >= '$today' ORDER BY date, starttime, endtime"; and $q = "SELECT * FROM villagehall WHERE book != '$cancel' ORDER BY date, starttime, endtime"; became $q = "SELECT * FROM villagehall WHERE date >= '$today' AND book != '$cancel' ORDER BY date, starttime, endtime"; 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.
Note: Your post will require moderator approval before it will be visible.