The Little Guy Posted August 27, 2007 Share Posted August 27, 2007 OK, here is my problem. I have 2 text fields, one for zip code, and one for a business name. If the user only enters in a zip code, it shows all the businesses in that zip code. If the user leaves the zip code as is, and adds a business in the business field such as: "Dick's Sporting Goods", it won't display that business. If the user keeps the zip code, and instead of "Dick's Sporting Goods" he/she puts "Sporting" it works, and displays that business. Test it: http://publicsize.com/rate_my_business/index1 change the drop down to "Zip Code" Business: Dick's Sporting Goods Zip Code: 55306 <?php if(isset($_GET['q'])){ $qQuery = addslashes($_GET['q']); $qQuery = explode(" ",$qQuery); $qQuery = implode("%",$qQuery); } if(isset($_GET['zip'])){ $zipQuery = addslashes($_GET['zip']); } $query = "SELECT * FROM rateMyBusiness WHERE zip = '$zipQuery' "; if(!empty($_GET['q'])){ $query .= " AND business LIKE '%$qQuery%' "; } $sql = mysqli_query($db,$query)or die(mysqli_error($db)); ?> Link to comment https://forums.phpfreaks.com/topic/66936-query-not-working/ Share on other sites More sharing options...
The Little Guy Posted August 27, 2007 Author Share Posted August 27, 2007 OK... I think that it is because of the quote in dick's How can I fix it? It works if I do "dick sporting goods" Link to comment https://forums.phpfreaks.com/topic/66936-query-not-working/#findComment-335601 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.