Search Script - More Advanced To Account For Multiple Criteria Strings
I am wanting to search one of my databases, which I have sucessfully achieved using the code: PHP Code:
SELECT DISTINCT Plus.Desc, Cstr(Price) AS string_price FROM Plus WHERE Plus.Desc LIKE '%".$criteria."%'"
I need to make this script more advanced to account for multiple criteria strings. I.e. If the criteria is "Gloss Paint" I want the results to bring up all the products described with either of the two words in the criteria, so it may bring up the products "gloss 5L white" and also "matt paint 5L", whereas, at the moment with the script, only the products with both the two words will appear, i.e. "gloss paint 5L". which obviously limits the results to very few and is very ineficient.
View Complete Forum Thread with Replies
Related Forum Messages:
Multiple Search Criteria...
In developing a site, mysql and php backbone, ive created a search functionality to the site. I have multiple search criteria which the user can select and then it, well i plan it to bring up the most relevant and closest matched results to that search. Ok the idea is great, but the know-how is flimsy. How can i generate a search script in PHP which will display the most relevant results in ascending order?? I currently have these search listboxes: generated dynamically from mysql: 1. Accommodation / Holiday type: 2. Location: 3. Facility 1: 4. Facility 2: 5: Facility 3: The Facility searches, each have 72 listbox options (Yuk, but i couldnt think of a better way of doing it) which are all the same in the 3 separate listboxes. What i want to do is match up a venue with the most corresponding search criteria.
View Replies !
Multiple Search Criteria
I'm creating a search feature that will allow users to search for items. The search has 3 criteria - Designer, Style, Colour. Each are presented in their own drop down box, all within one form. Problem: I've created code that works perfectly when users select something from all three criteria although my problem arises if they choose just one criteria e.g. (All Red items). At present they would be informed that 'no items are found', so depending on the various criteria they've chosen the info needs to be directed to different sql statements. I do want to keep it to one 'search' button.
View Replies !
Search DB Using Multiple Search Criteria On Web Form
I have a mysql database with a table with fields ( surname, company, speciality etc..) I created a simple form so people can search using criterias ( a search field which query all fields , a drop down with the list of surname, drop down with the list of speciality, drop down with a list of countries ). My system works perfectly well as long as I use only one criteria, However if I select "Plumber" as the speciality and "Scotland" as country, I will get all the entries for Scotland ( even if the speciality is not "plumber") and I will get all the entries for "Plumber" ( even if the coutry is not "Scotland"). Code:
View Replies !
Advanced Search - Listing Multiple Results
I created a seach function to search a database and retrieve the information based on the input. However only the first matching result is shown. The code is working fine but i want to show every matching result, one after another. Therefore, for example, if the user types into "country" the word "USA" every event will be shown. I have included the code i have used so far. Code:
View Replies !
Search Engine Friendly Search Criteria
I'm developing a site that finds things within a database. So if I have... find.php?var1=2&var2=3&var3=4..., those things are criteria for a search. One of the variables might be missing, or extra could be added. For example it could only be var1 and var 3: find.php?var1=2&var3=4. Would it make sence to make the url in the form "find/2/4"? The problem I have with that is how would I be able to identify which of the values correspond to which variable. Another option with this would be to use Sessions instead of passing variables through the url. Would that make it Search Engine Friendly? Also would it make a difference if I store SID within the url or within cookies? And if I do store the SID withing the url, should I somehow mod the url to make the SID appear as a folder?
View Replies !
Search Criteria
I want to be able to process a form with 4 input fields according to how many fields are filled out. If only one is filled, it searches on that, if two it searches accordingly etc. I have all the select statements for each instance working I just don't know the best way to call them. Would it be an if else statement ( perhaps if(!isset???) that would call each script or is there a better way.
View Replies !
Cannot Get A Search To Work With The Criteria
I am trying to develope a databse for travel reviews. So far people can submit articles to my database but I cannot get a search to work with the criteria I want. I have tried to find tutorials online but none of them do what I need. Code:
View Replies !
Building Search Criteria
I am trying to write a page that returns values based on drop down box values submitted by the user. It's going well except when this situation happens: Code:
View Replies !
Checkboxes Data In Datbase?. How Can I Match With Search Criteria?
INSERT form:I have a form with 5 checkboxes. I am storing it in datbase as varchar by combining all checked values with ":"(EX:0:1:2:4). Till here its ok I am storing data in schoolstate feild with data (0:3). Now I have a SEARCH form where i will give above 5 check boxes as critera. Now i Strucked at comparing these values to get results. Now i am not able to get matched records with 0,3 criteria in search form. I am not getting any ideas how to do this?
View Replies !
Advanced Search
Im looking to do one of the more advanced searches where you have a form you can narrow the search by username, user type, date entered, etc. Everywhere I've looked all I can find is the basic searches. Can someone point me in the right direction or show me some code.
View Replies !
Advanced Search Replace
im developing a script which grabs remote html files and shows them on the local server, ive written some code which changes the path of image files to point to the files on the remote server, this code can be seen below: Code:
View Replies !
Advanced Search Function
I'm trying to write an advanced filter function. Sofar I have 5 parameters which could lead to 25 possible queries. Instead of having to write them all, how do people normally tackle this problem?
View Replies !
Search In A File (advanced)
1. What do I want to do? I wish to create a search <FORM> to search in the contents of a text file located somewhere on the server. I wish to be able to: a) set a search criteria which is different from exact phrase Example: Searching Blue monkey happy should find Happy blue monkey b) set a search criteria with case INsensitive Example: Searching HAPPY BlUe MonKeY should find Happy blue monkey c) as the text file contains lines with a unique record on each; and on each line there are words separated by a TAB delimiter, I would like: - if a part of the line in the file matches the search criteria, the WHOLE line has to be printed; - results have to be printed in a <TABLE> with <TR> for every line match and <TD> for every word between the TAB delimiters in the file. Code:
View Replies !
Advanced Search Engine
I have a couple of sites built with different databases because all these sites are under different subject. And the databases have been built for a long time already. I want to make a global search engine so if you search for ie. "berry", it would display results from all databases that have the search word. Right now, if people want to search for "berry", they would have to go to my A database to search for it. Then if they want to search for "berry" from my B database, they would have to go there to search. So it's very inconvenient. I know I could just incorporate all the databases together into one big database, but I don't want to do that.
View Replies !
Advanced Search With Relevance Using Php And Mysql
I am working on a classifieds site that allows users to search for ads using many options. For example in the rentals area the user can select how many bedrooms, bathrooms, if pets are allowed, etc. There are currently 9 fields that i am allowing them to search on. I already found a great class on this forum that will make the dynamic mysql select statment, but i was unable to find much info on relevance displaying the best matching result first and the second best second and so on. I found a couple of tutorials but they were talking about matching a single word and the only relevance was that they were listing results higher depending on which result has the search string the most times. What i am trying to do is order relevance by having the top match be the one that matches closest to the 9 selections the user entered. So i would want any exact matches of all 9 fields at the top and then the list of matches would get less and less exact as you go farther down into the results. My initial thought was to make more than one mysql select, having the first select match all the searched fields exactly, and then the next select would do the same thing except one of the fields would be changed to find all of that one field that are not equal to what the user entered. example: PHP Code:
View Replies !
Advanced Search Template -- About Programming.
I know nothing about programming but I am building a website (written with php) that allow people post some info. Is there a site I can get some templates or php scripts for an advanced search function? The Advanced Search function shall able to search any posted info by a postal code/zip code within certain kms and be able to search by map by clicking to US/Canada map to get to state, then to cities than to towns....
View Replies !
Advanced Search W/ Multi-Select Array
I'm working on a site that deals with a MySQL database of stores across the country. I'm implementing an 'advanced search' section, and I can't for the life of me figure out how to handle queries that are derived of variables coming from multi-select lists. It seems like it would be an obvious thing, just going off the sheer ubiquity of similar search pages out there, but I just can't seem to come up with the logic behind it. Code:
View Replies !
Prevent Multiple People Using One Account
I have a website with premium and free members. Premium members, it goes without saying, need to pay before they can enjoy some special features within the site. Now, I want to prevent premium members share their ID and password with others. My current plan is to log every request by premium ID in the database and later observe the log file to determine whether an ID has been shared or not. My table will hold: the user ID, date and time, page requested, and IP address. If 2 different IP address are accessing the page within my website using the same ID within a very close time. Then the ID should be marked as 'shared'.
View Replies !
How To Restrict Multiple Login Using A Single Account.
In my project there is a requirement. If a user logged in at a time since he/she logged out others are not allowed to loggin using the same user name. That is to avoid multiple logins using a account. How to do this? I had got a idea and implemented. 1. When a user logs in storing the username, ip, login time to db. 2. When a User logs in i'll check the table whether the username exists in the table or not if yes i'll not allow the user to login else i'll allow to loggin. 3. When he logs out i'll delete the record from the table. Then he/ she can login again. But there is a problem in this the user can close the browser directly or right click in the taskbar and close it or by pressing Alt + F4. So for this i have to catch the things in Javascript and trigger the logout. Is is possible to catch the events in Javascript, if yes please provide me. Or Is there any other method to restrict multiple login using single account.
View Replies !
Run Multiple Strings?
This works fine: Code: $developer_query = mysql_query("SELECT * FROM accounts WHERE level<=ƈ'"); However, that will include all information in table.level 0, 1, 2 ... i want to EXCLUDE 1 ... i have tried: Code: $developer_query = mysql_query("SELECT * FROM accounts WHERE level=ƈ' AND level=Ɔ'"); however, we all know that that wont work. how can i make it so it only select 0 and 2, without having to run multiple strings?
View Replies !
Match Multiple Strings
I was using eregi() to search for a particular string in comments posted in a form. Now I need to search for a few other strings. Does eregi() have this capability (if it does, I haven't found the reference) or will I have to resort to some other technique.
View Replies !
Updating Strings In Multiple Tables
a. I have to update my addressbook when a company changes name ( eg: XYZ Inc. becomes XYZ Systems Inc) and I do this using $sqlb = "UPDATE `Adbk` SET `Company`='$company' WHERE `Cid` = $cid "; b. I also have to simutaneously update the Shipping Table so that the new name gets reflected there. I tried the foll. two options both of which dont work . PHP Code:
View Replies !
How To Search Strings Escaped By Mysql Real Escape String()?
I am currently developing an article script and there are Titles and Contents. To prevent sql injection, people say we must use mysql_real_escape_string(). So let's say if there is a Title that says "My Friend's best friend", if I look into the MySQL table record, the text will be saved as "My Friend's best friend", where the apostrophe is escaped. Code:
View Replies !
Splitting Strings - Break Strings Apart By Character
I am trying to make post code search and need to be able to break strings apart by character. I can do it by spaces and things using the explode() function, but I want to be able to get the first letter of the string only, the first and second only, first second and third etc.
View Replies !
Multiple Keyword Search
Ok, here's the scoop. This code snippet was working fine until just recently. It is possible something was upgraded on the server, but I'm not sure what the original version of mysql was. This snippet takes a multiple or single keyword search trims and explodes it, and then performs the search. The search works fine if you enter a single keyword but as soon as you enter multiple keywords the query fails. It prints out the "Query Failed" message. I changed the method= to "Get" so I could see if there were any errors and it is exactly as it should be, multiple keywords end up with a "+" between them. Suggestions? thanks chris <? //error message (not found message) $XX = "Sorry, No Records Found"; //Putting all individual words in an array if ($search) { $search = trim($search); // delete surrounding spaces $search = explode(" ", $search); // make array of individual words } //Definition of the query $selectquery = " SELECT * FROM Products "; //Cycle through the words-array if there are word(s) filled in if (isset($search)) { $selectquery .= " WHERE "; for($i=0; $i < count($search); $i++) { $selectquery .= " $column LIKE '%" . $search[$i] ."%' "; if ($i < count($search)-1) { $selectquery .= " ORDER by Description "; } } } $result = mysql_query ($selectquery) or die ("Query failed"); // this is where multiple keywords kills it while ($row = mysql_fetch_array($result)) { print statements...
View Replies !
Multiple Search Results
I have a php script which searches a mysql database and returns and lists the results 25 records per page. I am using the offset to do this. It works well. But I am outputing the search results 1 record per line, 25 records per page, with links to the previous and next pages, etc. What I really want is to list the results in a 5 X 5 table. ie the first 5 records on table row 1, the next 5 on table row 2, etc. Obviously for the last page there may not be 25 records, but anything from 1 to 25. How can I automatically output html to produce the table and populate each cell with a record from the search result?
View Replies !
Multiple Drop Down Search
i created two dropdown lists. One lists the months. And one lists the years. I want to be able to populate a sql query with the choices the user makes in the dropdown to display the correct choices. PHP Code:
View Replies !
Multiple Table Search
I've been playing around with this and I can't quite find the right answer. I have two tables. One has a list of apartments with each having an id. The other has a list of the apartment's bedroom configurations, each one starts with the same id of the apartment. Now I'm using LEFT OUTER JOIN to get all of the apartments and their configuration. But now I get a list of every apartment, plus each of it's configurations. What I want is just the list of the apartment itself. Instead of the results coming back with 6 of one apartment, I just want it to show me the apartment once... Anyone?
View Replies !
Search Multiple Words?
in my search if i do 1 word say: graham it searches and find it ok but if there is characters in between them say graham-another word.another word the characters after the work seem to bring back no results basically i just need to search the word graham to get results the minute i put 2 or more words together the reults bring back nothing is there a way to be able to search multiple words? code: part of the query $search_query .= "WHERE (`file_name` LIKE '%$keywords%' OR `file_name` LIKE '%$keywords%')";
View Replies !
Multiple Search Queries
I have no code to post as of yet, just want to know whats going to be the best route to take. Im going to have 3 or 4 drop down boxes each one allowing the user to define the search in differnt ways. Whats going to be the best way to carry the variables? Im thinking the post method but not sure. Any ideas?
View Replies !
Multiple Search Parameters
I have a quick search form for my site. There are three parameters: horse breed, zip code, and location. Users don't have to enter all of the information, rather 1 parameter or 2 or all. My problem is I can get the code for the zip code to work, but when I go to code in the rest of the parameters the code seems to stall. Anyone that can give a little light on this problem would be a great help. I have been working on this problem for days with no help. Once I figure out this problem I can go on to make an advanced search with many more parameters.
View Replies !
Search Multiple Tables At Once
I have about 50 or 60 tables, and I want to be able to search each table to search for a specific username, and to count how many tables the user is found in. Can I do this with a loop? The username may or may not exist in all tables, so I'm not certain if the loop will time out not finding a name, or if will just stop at the first table it doesn't find a match. I'd like to really try and figure this on my own, as I'm slowly getting better here with php. But if someone can just give maybe a Yes or No answer, and which loop to would be best (ie a for loop or while loop).
View Replies !
Search Multiple Tables
I understand from other threads that FULL TEXT search is not possible when using multiple tables. I am trying to develop a search function that enables a keyword to be entered into a textbox- the user hits enter and a list of sections with relevant titles and URL's is displayed. Code:
View Replies !
Search A Multiple Fields
Im just programming some bits and pieces. Just wondering if I can do a search a table across multpile fields. I mean if i have a text box & put a general search, can i get it to search across the whole table to matching entries. select * from county where "any field" = 'mysearchword'.
View Replies !
Search With Multiple Words Only?
Simply put I want the search to produce only the results with Every word in the search requested. For example. If a user types in 2005 Barry Bonds. (This is a sports auction site) I only want the query to produce auctions that have <b>all</b>3 words in them in any order. As it stands I get results with 2005 and barry and bonds. I need to narrow the search.
View Replies !
Search Multiple Fields
I use two or more words that appear in different fields of the table. For example, search term 'John' appears in field[wname] and 'canada' appears in field[country]. But when I type 'john canada' into my search form I get no results unless I only use one or the other in the search form. It also does not work if I type in any extra words whether they are in the table or not. It probably has something to do with this: wname LIKE '%$search%' I need to search multiple fields without having exact matches: ------> Begin Code $sql= mysql_query("SELECT wname, url, title, keywords, description, city, country, category FROM directory WHERE city LIKE '%$search%' ¦¦ wname LIKE '%$search%' ¦¦ title LIKE '%$search%' ¦¦ keywords LIKE '%$search%' ¦¦ description LIKE '%$search%' ¦¦ country LIKE '%$search%' ¦¦ category LIKE '%$search%' ¦¦ url LIKE '%$search%'", $db);
View Replies !
Multiple Select Box Search Queries
I am trying to create an elegant query together with a multiple select box, tbl_level linked by a foreign key. Sample code below: $sql = "SELECT DISTINCT Firstname,.... FROM .... "; //conditional statement to determine whether WHERE clause is needed if($_POST["FirstName"] != "" { $sql .= "WHERE "; if($_POST["Firstname"] != "") { $sql .= "Firstname LIKE "".addslashes($_POST["Firstname"]).""" } //select box entries array Level if($_POST["Level"] != ""){ $i=0;$query.="( "; foreach ($_POST["Level"] as $val{ if ($i >0){$query.= " AND ";} $query .= "tbl_level.LevelCatID LIKE $val "; $i=1;} $query.=" )"; $query.= " AND tbl_name.NameID = tbl_level.NameID"; } //query database I can't use this as only a single Level select selection works, if user selects more , I can' t search the Level column for 2nd input from the select box using this. I am trying to avoid too many calls to the database, As I have several multiple select options for user to input for searching.Am trying to call single complex query at the end of code.
View Replies !
Multiple Search Engine Script
anyone know if there is a free script available that works similar to the multiple search engine on dogpile, i've found a few that open a new window for each engine searched but none that return the results on the same page. Would something like this be available as a free script?
View Replies !
Multiple Search With More Than 2 Drop Down Menu
I have problem with multiple search with more than 2 drop down menu. After submit from search.htm, in the results.php page i dont get results or error and i dont know where the problem is. look my code and tell me if you see something or error in sourcecode PHP Code:
View Replies !
Multiple Drop Down's For Search
I am looking at adding a search section to my site whereby visitors select from two drop down menu's and the desired page is displayed. Similarly to many friend finder sites whereby you can select the age,sex and country of the person you are searching for. Is there a way to do this without needing a database ?
View Replies !
Multiple Table Search With Mysql
i want to search multiple tables to see whether a certain user has posted more than three times in any category in my database. how can i do a search for the same field in different tables?
View Replies !
MySQL Allows Multiple Words To Search
I need a search that allows multiple words. I got started on the following by code others posted here before. $search = 'S 1' $searcha = Array(); $searcha = explode(" ", $search); $query = "select * from Story where 1=1 "; reset($searcha); while (list($key, $val) = each($searcha)) {$query.= "and Description LIKE '%$val%'"; } Description is a field in my table that contains the description of the story and the story number. ("This story is about garden planting, S 18"). Basically, the code works fine. The thing is when I search for "S 1" (story number 1), because of the "LIKE '%$val%'" clause, the query will basically return everything that starts with a "S" and everything that starts with an "1". So even though I search for "S 1", "S 18" will come up as well.
View Replies !
MySql PHP Multiple Search Prob
Hope am posting in right place, am working on a real estate site, normally i just filter the records by one field but this time they want them filtered by Town, Type, Price and Bedrooms. I have the selection boxes taking their information from the database, but I can't seem to get the form to pass the variables correctly to the next page, either that or my MySql query is all wrong. Was hoping someone might be able to tell me what i'm doing wrong, this is my form on the properties_search.php page: Code:
View Replies !
Search Multiple Column Query
I have some code, this isn't all of it, I figured this is the bit I need to change : $query = "select * from companies where company like "%$trimmed%"  order by company" I want it to search multiple column like 'tel' as well as 'company' I've tried: $query = "select * from companies where company, tel like "%$trimmed%"  order by company" But doenst seem to work. Can anyone tell me what to change or should I post the rest of the code so someone can help?
View Replies !
|