Jessy20 Posted April 11, 2014 Share Posted April 11, 2014 Hi, Im trying to create a form that will allow a user to search for another user via their city and what sports they like. I have so far three sections of code: <?phpif(isset($_POST['submit'])) { // The form has been sent so show the results} else { // Show the form}?> That piece of code i have no idea on but it basically needs to check if the form has been subbmited, then show the search results if it has and if not then display the search form. <form name="input2" action="search.php" method="post" ><b>City:</b> <name="licity"> <?phpecho'<select name="cities">';foreach($citynames as $city){echo'<option value="'.$city.'">'.$city.'</option>';}echo'</select>';?><b>Sports:</b> <name="lisports"> <?phpecho'<select name="sports">';foreach($sportnames as $sports){echo'<option value="'.$sports.'">'.$sports.'</option>';}echo'</select>';?> <input type="submit" value="Search" name="lisearch"></form> This part is just the form to list the different cities and sports so the user can search via both of them. <?php$query = "SELECT user.user_id, user.user_firstname, user.user_surname ". "FROM user, usersport ". "WHERE user.user_id = usersport.usersport_user_id AND usersport_sport_id = '".$_POST['sport']."'AND user_city = '".$_POST['city']."'AND user_id != '".$_SESSION['id']."'";?> This third part gets the data from the database tables depending on what the user has searched for. Anyone have any ideas? I know its alot of code and might be confusing but any help would be great! Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/287700-php-search/ Share on other sites More sharing options...
gristoi Posted April 11, 2014 Share Posted April 11, 2014 have you actually done any work on this, or just found it on the internet? Quote Link to comment https://forums.phpfreaks.com/topic/287700-php-search/#findComment-1475783 Share on other sites More sharing options...
QuickOldCar Posted April 12, 2014 Share Posted April 12, 2014 What you have there is more like a select this and that....it shows results. Do you want information on how to do a normal search? using LIKE ? Personally i like using fulltext search as it simplifies multiple keyword searches. https://dev.mysql.com/doc/refman/5.7/en/fulltext-boolean.html Quote Link to comment https://forums.phpfreaks.com/topic/287700-php-search/#findComment-1475840 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.