By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,303 Members | 1,245 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,303 IT Pros & Developers. It's quick & easy.

Need help with a search code.

P: n/a
Hey ya guys. Just a pre thank you for any help or info.

Basically here is what is going on. I have a search engine I've been working
on and as of right now it is working with multiple key words. The problem
I'm having is that when you enter a search term it will bounce back
everything for each key word and not comparing them. I honestly don't know
how to do this, being new to the whole PHP/SQL.

This is what I'm using right now for the mysql string to search:
$result = mysql_query("SELECT * FROM ptvideos2 WHERE search LIKE
'%$search_words[$i]%' ");

any ideas?

Oct 6 '08 #1
Share this Question
Share on Google+
4 Replies


P: n/a
--~AngelisIIDX~-- wrote:
Hey ya guys. Just a pre thank you for any help or info.

Basically here is what is going on. I have a search engine I've been
working on and as of right now it is working with multiple key words.
The problem I'm having is that when you enter a search term it will
bounce back everything for each key word and not comparing them. I
honestly don't know how to do this, being new to the whole PHP/SQL.

This is what I'm using right now for the mysql string to search:
$result = mysql_query("SELECT * FROM ptvideos2 WHERE search LIKE
'%$search_words[$i]%' ");

any ideas?
I suggest you ask SQL questions in comp.databases.mysql. You'll get
better help over there.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Oct 7 '08 #2

P: n/a
--~AngelisIIDX~-- wrote:
Hey ya guys. Just a pre thank you for any help or info.

Basically here is what is going on. I have a search engine I've been
working on and as of right now it is working with multiple key words.
The problem I'm having is that when you enter a search term it will
bounce back everything for each key word and not comparing them. I
honestly don't know how to do this, being new to the whole PHP/SQL.

This is what I'm using right now for the mysql string to search:
$result = mysql_query("SELECT * FROM ptvideos2 WHERE search LIKE
'%$search_words[$i]%' ");

any ideas?
what you probably want is something like:
$sql = "SELECT * FROM ptvideos2 WHERE ";
$oper = "";
foreach( $search_words, $aword) {
$sql = $sql . "search LIKE %" . $aword . "%" . $oper;
$oper = " AND ";
}
$result = mysql_query($sql);

But boy is this going to be slow on any appreciable sized db. Do a
google search on text searching or inverted indexes.

PS This is untested code, off the top of my head. Test extensively
before using.
Oct 7 '08 #3

P: n/a
--~AngelisIIDX~-- wrote:
I have a search engine I've been
working on and
any ideas?
Google hyperestraier
Oct 7 '08 #4

P: n/a
On Oct 7, 12:19*am, "--~AngelisIIDX~--" <fwrote:
Hey ya guys. Just a pre thank you for any help or info.

Basically here is what is going on. I have a search engine I've been working
on and as of right now it is working with multiple key words. The problem
I'm having is that when you enter a search term it will bounce back
everything for each key word and not comparing them. I honestly don't know
how to do this, being new to the whole PHP/SQL.

This is what I'm using right now for the mysql string to search:
$result = mysql_query("SELECT * FROM ptvideos2 WHERE search LIKE
'%$search_words[$i]%' ");

any ideas?
You have to fetch almost everything from database, and have to process
it according to your algorythm. I suggest use Php Data Objects - PDO -
class, processing become much easier.
Oct 8 '08 #5

This discussion thread is closed

Replies have been disabled for this discussion.