I am building a new website and want to add search to the site. I know google offers free and paid solutions but I would prefer to develop something myself if possible. How difficult and what steps would I need to take to put something together?
Is the site flat html? No php or anything? I would simply put all the pages into a database and just make that searchable.
Can we see your site? I am sure we can help you.
I haven't put the site online yet otherwise I'd post a url. Currently, I have only used html, css and some javascript. I don't know much php but was considering using php includes for repeated elements like the header, navigation and footer.
Unfortunately I don't currently know how to put my entire site in a database. If the learning curve for the php/mysql isn't too bad I welcome any suggestions, links or other references I could use. Thanks for your help.
Just making the content searchable shouldnt be hard to learn.
Do you have phpmyadmin?
One method would be to make a table with any name you like really id probably use something like "content" or something.
Id probably put something like "id", "title", "url", "content"
then just use phpmyadmin to put it in there
I will assume you can make a form that sends get data?
then using that post data do something like:
Code:$q = explode(' ', $_GET['q']);
foreach($q as $word) {
$q2 .= " `content` LIKE '%{$word}%' OR";
}
$query = mysql_query("SELECT title, url FROM `content` WHERE ".substr($q2, 0, -3));
while($row=mysql_fetch_assoc($query)) {
echo '<a href="'.$row[url].'">'.$row[title].'</a><br />';
}
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks