How do I check a part of a record for a string?

One example is, if someone does research online for " abcde" and I’d prefer to find every record who has " abcde" any place in it, how to I realize record

Searching what MySQL database family table, a text record, an array, some sort of string

Now i am using php browsing a MySQL databases.

WHERE industry LIKE ‘%whatever a person’s term is%’

Imagine if it’s 2 words as well as the 2 words aren’t together inside string For case, the search is definitely " nike shoe". In case your record has " nike shoes" or even " shoes just like Adidas and Nike". Notice top of the and lower conditions also.

I don’t understand how to do a case-sensitive research in MySQL, or even if it’s possibly possible.

But you can easily adequate modify that query to read:

WHERE industry LIKE ‘%nike%’ and industry LIKE ‘%adidas%’

MySQL just isn’t case-sensitive.
That will force it, you have to specify BIN (binary) for a byte-by-byte match.
So you’re OK with all the cases.

Consequently, if a customer searches " nike" it can find " Nike" Bear in mind it’s a Linux server.

That is definitely correct.
In case I’m wrong, please okay know.


ought to all work.

How would I hunt for an unknown variety of words. Say the user searches " nike shoe" along with the next searches " red nike shoe" What I’m attempting to do here is build a search after " explode" operate. I can’t recognize LIKE $word1 AND ALSO LIKE $word2… etc when I have no idea of how many words can be entered.

Here’s what We’ve.


$searchwords = $_GET'search';
indicate $searchwords; // that will debug
$word = explode(" ", $searchwords);

$wordnumber = count($word);

$searching = " SIMILAR TO '%". $word0. " %'";

if($wordnumber > 1)
for($number = 1; $number < = $wordnumber-1; $number++)
$searching = $searching. " PLUS LIKE '%". $word$number. " %'";

$sql = " DECIDE ON * FROM luv2kayak_items WHERE productTitle ". $searching. " PLUS published = 'Y'";

indicate $sql; // that will debug

$pageNum = $_GET'page';

$pageNum = 1;

$itemsPerPage = 15;
$offset = ($pageNum - 1) * $itemsPerPage;
$results = mysql_query($sql);
$numOfProducts = mysql_num_rows($results);

$sql. = " BUY BY id LIMIT $offset, $itemsPerPage";

$result = mysql_query($sql);

Plus I get

Word of caution: mysql_num_rows(): supplied argument just isn’t a valid MySQL outcome resource in mysite/searchresults. php on the web 39

Was your question working originally And also did you generate this entire script via scratch I often test my query’s with phpmyadmin before creating them while in the actual source signal. Try that… if you do some type involving php admin computer software installed.

I bought it to operate. I had to place productTitle knowledgeable so that it could be there in all the " like" vertisements.

This entry was posted in Web Design and tagged , , , , , , , , , , , , , , , , , , , . Bookmark the permalink.

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *