Web Design Forum HTML CSS JavaScript PHP Graphic Design SEO forum

Full Version: How can I put search option in my website??
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey,

I am new in this section, I want to put a search option in my website,i heard about php scripts could help, but is there anyone who has already that script and share with me please...

Cheers
(01-13-2011 11:22 AM)justinOrel Wrote: [ -> ]Hey,

I am new in this section, I want to put a search option in my website,i heard about php scripts could help, but is there anyone who has already that script and share with me please...

Cheers

Table: Members
Fields: id | username | password | completename | country
Records:
1 | test | test123 | Testing | Philippines
2 | shin | shin10 | Shin Shin | India

PHP Script - Search
Quote:<?php
/* include your database connection here */
if($_GET[Search]=="Search")
{
$q = $_GET['q'];
$sql = "SELECT * FROM Members WHERE completename LIKE '%$q%' OR username LIKE '%$q%' ";
$result = mysql_query($sql);
$rows = mysql_num_rows($result);
if($rows<=0)
{
echo "No Result(s) Found";
}
else
{
while($found = mysql_fetch_array($result))
{
echo "Username: " . $found[username] . "<br>";
echo "Password: " . $found[password] . "<br>";
echo "FullName: " . $found[completename] . "<br>";
echo "Country: " . $found[country] . "<br>";
echo "<br>";
}
}
}
?>

Search Term: Shin
Quote:Username: shin
Password: shin10
Fullname: Shin Shin
Country: India

Simple Search Form
Quote:<form method="GET" action="">
Enter any keyword<br>
<input type="text" name="q" value=""><br>
<input type="submit" name="Search" value="Search">
</form>
The code is provided to you, I wanted to know whether it worked well or was there any issue.
i use this link its help me more
you can write search function in your logic. In php site smarty framework is available for ready made template which will help you put ready made functionality.
First you have CGI access and that perl is installed. It also installs the script remotely for you if you answer a couple of questions for it (account username and password) which saves you from the installing it yourself.

I've used it for several years and have no issues with it.
the code provided is quite helpful
thanks for your useful post here good share here
Even the WordPress native search function is inferior to having
the mighty G do your search for you.
Reference URL's