Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

Help with Php database search engine!

Status
Not open for further replies.
Joined
Nov 17, 2008
Messages
800
Reaction score
1,392
Alright guys i have googled about this topic, and i guess i'm just not understanding the long codes. i basically need a text box, and when you type a word into the box, it'll search my database for things containing the word.

say my table looked like this

NAME JOB AGE
chris CEO 17
john CEO 39
CEO owner 45
tom Manager 26

and they searched "CEO"

i would want the first 3 to appear on a page.

is there any way to do this?

please help.

thank you for any future help!
 
Infraction Baɴɴed
Member
Joined
Apr 9, 2008
Messages
1,416
Reaction score
169
 
ex visor
Member
Joined
May 17, 2007
Messages
2,741
Reaction score
937
PHP:
<?PHP

include "config.php"; //requires database connection

echo "<h1>The following are CEOs of your company:</h1>";

$sql = mysql_query("SELECT * FROM `table` WHERE `JOB` LIKE '%ceo%' LIMIT 3") or die(mysql_error()); //change "TABLE" to your actual table name..

while($sqlly = mysql_fetch_assoc($sql)){
 echo "{$sqlly['NAME']} - {$sqlly['AGE']}<br/>";
}

?>
For the sake of simplicity.
Edit/do whatever you want to it.
 
Joined
Nov 17, 2008
Messages
800
Reaction score
1,392
PHP:
<?PHP

include "config.php"; //requires database connection

echo "<h1>The following are CEOs of your company:</h1>";

$sql = mysql_query("SELECT * FROM `table` WHERE `JOB` LIKE '%ceo%' LIMIT 3") or die(mysql_error()); //change "TABLE" to your actual table name..

while($sqlly = mysql_fetch_assoc($sql)){
 echo "{$sqlly['NAME']} - {$sqlly['AGE']}<br/>";
}

?>
For the sake of simplicity.
Edit/do whatever you want to it.
thank you very much! it helped me a lot. mods can close this thread now. :thumbup:
 
Infraction Baɴɴed
Member
Joined
Apr 9, 2008
Messages
1,416
Reaction score
169
@aaron
he learned nothing.

@on-topic
google does have the answer but you need to know what you want to do in order to find what you want.
 
Joined
Nov 17, 2008
Messages
800
Reaction score
1,392
@aaron
he learned nothing.

@on-topic
google does have the answer but you need to know what you want to do in order to find what you want.

what's your problem? people like you ruin the internet. i stated in my original post that i had looked at search results from google, yet still didn't understand.

i had originally thought that the query would be something like

Code:
"SELECT * FROM `table` WHERE `JOB` CONTAINS 'ceo' LIMIT 3

after realizing CONTAINS isn't a function, the part that helped me was the "LIKE" in

Code:
"SELECT * FROM `table` WHERE `JOB` LIKE '%ceo%' LIMIT 3

so yes, i did learn something.

EDIT:

and the fact that your link was lmgt4u made me not go to it. had i gone to it i most likely would have been helped sooner. i had no idea about the wildcard.
 
Last edited:
Infraction Baɴɴed
Member
Joined
Apr 9, 2008
Messages
1,416
Reaction score
169
people like me are awesome...

bookmark this site: youll learn alot because its for beginners and can help even advanced people along the way too. (good refresher for the MIND!)
 
ex visor
Member
Joined
May 17, 2007
Messages
2,741
Reaction score
937
What? lols. In terms of PHP? I don't think so.
 
Junior Spellweaver
Joined
Feb 7, 2008
Messages
186
Reaction score
19
Isn't this what a compiler is for...?
Uhmm a compiler for PHP, never heard of such a thing. Also Aaron how does it feel not being a part of the INFJ master race? With the same name as me I would assume we think the same.
 
Last edited:
ex visor
Member
Joined
May 17, 2007
Messages
2,741
Reaction score
937
Uhmm a compiler for PHP, never heard of such a thing. Also Aaron how does it feel not being a part of the INFJ master race? With the same name as me I would assume we think the same.

The what? And what? No. =3
 
ex visor
Member
Joined
May 17, 2007
Messages
2,741
Reaction score
937
What? And stop posting here and it'll die. I don't know about the driods.
 
Status
Not open for further replies.
Back
Top