sirtemplar Posted July 26, 2008 Share Posted July 26, 2008 i have a search form for book AUTHOR and TITLE from my database. Before, when user clicks the form without any input on AUTHOR or TITLE on the form, the script prints all data from database. now with the script below, user should input on AUTHOR and TITLE fields to get a result or else they get an error. BUT what i want is that AT LEAST they input on AUTHOR OR TITLE field, not both required. THANKS. {$Author = $_POST['Author'];} {$Title = $_POST['Title'];} if($_POST['Author'] == "" || $_POST['Title'] == "") { print "An error has occured. Author and Title require input"; } else { $result = mysql_query ("SELECT * FROM catalogue WHERE Author LIKE '%$Author%' AND Title LIKE '%$Title%' ORDER BY Title ASC, Author ",$conn); $totalrows = mysql_num_rows($result); if ($row = mysql_fetch_array($result)) { do { now it's not printing ALL anymore when there is no user input on the search form BUT now to search user must input on both fields! what i want is that AT LEAST they input on TITLE or AUTHOR field. Thanks for any help Link to comment https://forums.phpfreaks.com/topic/116692-solved-search-form-fill-at-least-one-field/ Share on other sites More sharing options...
Psycho Posted July 26, 2008 Share Posted July 26, 2008 Change || to && if($_POST['Author'] == "" && $_POST['Title'] == "") { print "An error has occured. Author and Title require input"; } Link to comment https://forums.phpfreaks.com/topic/116692-solved-search-form-fill-at-least-one-field/#findComment-600001 Share on other sites More sharing options...
sirtemplar Posted July 26, 2008 Author Share Posted July 26, 2008 thank you very much. IT WORKS!!! Link to comment https://forums.phpfreaks.com/topic/116692-solved-search-form-fill-at-least-one-field/#findComment-600006 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.