andrew_biggart Posted May 29, 2008 Share Posted May 29, 2008 Hey everyone i hope someone can help me i currently have added a search bar to my online auction site, when ever i search its working to an extent. It displays the selected categories no problem but brings up every item in the category, not just what i searched for. Im assuming this is because it is searching for each individual letter and not each word! I have tried $search = addslashes($_POST['search']); but i think this just takes away the white space. How do i define each word??? Im usuing the following code to do the search! The actuall search bar code is <form name="shop_search" method="post" action="results.php"> <img alt="search" src="search.gif" width="77" height="17" /><input name="q" type="text" id="search" style="width: 288px" /> <?php include("config3.php"); //get subjects from database $sql = "SELECT * FROM $tbl_name ORDER BY id;"; $result = mysql_query($sql); ?><select name="cat"> <?php //show subjects while($catrow = mysql_fetch_assoc($result)) { echo "<option value='" . $catrow['id'] . "'>" . $catrow['cat'] . "</option>"; } ?> </select> <input name="Submit1" type="submit" value="Search Urbanwear" /> </form> and the results page is as follows <?php include("config.php"); $search = addslashes($_POST['search']); $cat=($_POST['cat']); // Retrieve data from database $sql="SELECT * FROM $tbl_name WHERE item_name LIKE '%" . $search . "%' AND category_id LIKE $cat "; $result=mysql_query($sql); // Start looping rows in mysql database. while($rows=mysql_fetch_array($result)){ ?> any help or a poin in the right direction would be appreciated ! Thanks in advance Quote Link to comment Share on other sites More sharing options...
andrew_biggart Posted May 29, 2008 Author Share Posted May 29, 2008 Any one please !!! im stuck lol Quote Link to comment Share on other sites More sharing options...
Gighalen Posted May 29, 2008 Share Posted May 29, 2008 Eh, I'm not exactly sure what you're asking, but if your refering to how you can type in multiple keywords and look up that, you can just assign an explode function using someting like + or 'space' as a delimiter, and then run each of those through a query. 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.