|
|
|
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
php5 - A case for Preg match?
This one seemed simple at first but it's just not working like i expected.
Anyway the idea is simple. POST a subject to search with, the code scans the DB and spits out links to every page that uses that content $querystring4='SELECT * FROM Content WHERE Status = 1 AND IN Copy = "'.mysql_real_escape_string($_POST['searchword']).'"'; But it's just giving me a bad syntax error when i try to search using the IN operator on the Copy field.
__________________
29 years of creative writing 13 years of HTML 10 years of Photoshop 6 years of PHP/MySQL And I never knew Photoshop could do HTML until 2004! You learn something new every day. |
|
#2
|
|||
|
|||
|
your using it wrong. IN works mostly like the php function in_array() but instead of an array you can use a sub query to pull back one column from a table or you can pass a comma separated list of strings instead. If your search is supposed to be a partial match, you should use LIKE '$search%'. that will pull back any string starting with $search. if it is an exact match then you can just use the good ol' "=" and if you want more like an actual search engine where multiple words are matches and rows are pulled back based on how close they match all/some of a string then you will want to look into a full_text search which you specify a column to create a full_text index on and it will go through and map all the words in the column with their frequency of use and return results that best match the string entered.
|
|
#3
|
|||
|
|||
|
Quote:
Sooooo.... $querystring4='SELECT * FROM Content WHERE Status = 1 AND Copy LIKE "'.mysql_real_escape_string($_POST['searchword']).'"'; ?? Where can i find out more info about "full_text" as well? |
|
#4
|
|||
|
|||
|
Quote:
just pinging the forum as i'm still a little confused here |
|
#5
|
|||
|
|||
|
mysql manual on full text searching
http://dev.mysql.com/doc/refman/5.0...ext-search.html tutorial on using full text searching http://devzone.zend.com/article/1304 |
![]() |
| Viewing: Codewalkers Forums > PHP Related > PHP Coding > php5 - A case for Preg match? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|