Jump to content

php search engine


onthespot

Recommended Posts

dear friend,
if you are using mySQL to store the profiles of your registered users then you can execute an mysql query using PHP to display the users registered with you. but it depends what database or technology you are using to store the profiles of your users. and the same is what you have not mentioned.
Link to comment
https://forums.phpfreaks.com/topic/17292-php-search-engine/#findComment-73388
Share on other sites

also tho, say my profiles are on the end of the address so

http://mysite.com/username1
http://mysite.com/username2
http://mysite.com/username3

amd when i search i want the search to search for the profiles using the usernames!

is there anyway it can literally search the profiles on the end of addresses?
Link to comment
https://forums.phpfreaks.com/topic/17292-php-search-engine/#findComment-73461
Share on other sites

dear friend,
the problem is simple and you are making it complicated. just goto a website that offers tutorials for PHP and look for a tutorial that refers to searching through databases. thats it, you will surely find your answer there.
what i asked you initially was about the database you use. if it is MySQL then you can place a form tag for search'ing purpose and put action="abc.php".
then in abc.php you can put the code that produces the result from mySQL database.
suppose that the visitor to your website is looking for a username similar to $username.
then you can put the following in your abc.php file

[quote]
// connect to the server
if (!($link=mysql_pconnect($dbhostname,$dbusername,$dbpassword))) {
echo ("error connecting to the server");
exit();
}

// select the database
if (!mysql_select_db($database,$link)) {
echo ("error selecting the database");
exit();
}

// search for the requested/required username
$details = "SELECT * FROM dbtablename WHERE username LIKE '%$username%';
if (!($result = mysql_query($details,$link))) {
echo ("no match found".mysql_error());
exit();
}

// print the result if match is found
while ($myrow = mysql_fetch_array($result)) {
echo $myrow['username'];    // here you can print all the profiles you have. $myrow[] is an array and you have to place in [ here ] the values of entities placed in your db table.
}

[/quote]

i hope that i have made it easier for you.
Link to comment
https://forums.phpfreaks.com/topic/17292-php-search-engine/#findComment-73484
Share on other sites

got a problem
ive installed that script, this is the form

<form action='profilesearch.php' method=get>
<input name=search type=text value='Enter username' />
<input type=submit name='user' value='Find Player' class=button />
</form></p>

to go with that, ive put all the details into the script about! then when i enter the username into the form, i get a blank screen, and in the url bar, /profilesearch.php?search=Enter+username&user=Find+Player, when i search ! whats wrong?
Link to comment
https://forums.phpfreaks.com/topic/17292-php-search-engine/#findComment-73821
Share on other sites

using that code he gave you, just change this:
[code]

// search for the requested/required username
$details = "SELECT * FROM dbtablename WHERE username LIKE '%$username%';
if (!($result = mysql_query($details,$link))) {
  echo ("no match found".mysql_error());
  exit();
}
[/code]
to tihs
[code]

// search for the requested/required username
$username = $_GET['search'];
$details = "SELECT * FROM dbtablename WHERE username LIKE '%$username%';
if (!($result = mysql_query($details,$link))) {
  echo ("no match found".mysql_error());
  exit();
}
[/code]

maybe that'll help
Link to comment
https://forums.phpfreaks.com/topic/17292-php-search-engine/#findComment-73826
Share on other sites

ok here, here ya go:
[code]
// search for the requested/required username
$username = $_GET['search'];
$details = "SELECT * FROM dbtablename WHERE username LIKE '%$username%';
if (!($result = mysql_query($details,$link))) {
  echo ("no match found".mysql_error());
  exit();
}

// print the result if match is found
while ($myrow = mysql_fetch_array($result)) {
echo "<a href='http://yoursite.com/" .$myrow['username'] . "'>" . $myrow['username'] . "</a>";    // here you can print all the profiles you have. $myrow[] is an array and you have to place in [ here ] the values of entities placed in your db table.
}
[/code]
be sure to replace yoursite.com with your site.. you did see it finds profiles like http://whatever.com/username right?
Link to comment
https://forums.phpfreaks.com/topic/17292-php-search-engine/#findComment-73842
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.