Creating a Functioning Search Bar

I am trying to create s functioning search bar in my website. I am new to web dev and have read that you can do this by creating a PHP file. I am not fully sure how to do this, can any one enlighten me?

Below is my code for my search bar.

[code]

[/code]

What you have given is the most basic forum function in html.

If you use a database then you will have to start making keywords.
Then use the keywords as your search.
Or search the description or title of what ever you intend to search from the database.

But you cannot just use a form to search your site.
Do you have a database ?
or an array of keywords per page ?

This will not be easy for someone that does not know php or mysql and has a static website is your site in php ?

I do not have a data base or an array of key words per page. My site is in HTML, I don’t know php very well. What would an array of words look like? You can see my page by going to www.homesandinvestments.com. The search bar is not functionalbe.

Well what will they be searching for ?
Does your server support php ?
I do not see anything to search for you have a hand full of pages.
It would not take me any longer to click the pages you have then to type in something to search.

You could make a small php script that loads the html in to its memory then search the text if the text is there it could show the page but if someone searches and the it will be in every page.

If you make a list of words in an array search the words and then if found in the array print the link to send them to.

only example code.
[php]$my_array(‘money’,‘banking’,‘property’);
$my_other_array(‘letter’,‘paper’,‘news’,‘giberish’)
$search= $_POST[‘search’];

if (in_array($my_array, $search)){
echo ‘found on page Investments’;
}else if (in_array($my_other_array, $search)){
echo ‘found on page Banking’;
}else{
echo ‘nothing found’;
}

[/php]

Here is a basic tutorial on searching a database as you type and getting results back. See if it helps.

http://www.phphelp.com/forum/index.php?topic=17363.0

Sponsor our Newsletter | Privacy Policy | Terms of Service