Jump to content

Search Functionality?


random1

Recommended Posts

Is there a better way to add a search engine to a PHP site?

 

I currently have something similar to:

 

http://www.pixel2life.com/publish/tutorials/707/create_your_own_php_mysql_search_engine/

 

but I am looking for these features:

 

  • pagination of results (pages)
  • boldening of search term in results
  • quick response and recommendation of mispellings

 

Any help would be appreciated.

Link to comment
https://forums.phpfreaks.com/topic/144605-search-functionality/
Share on other sites

For pagination check out the tutorial here at phpfreaks CLICKY

 

This should be fairly simple to implement with the code that you're using, give it a try.

 

For boldening of search terms you can do it with a simple str_replace or for more functionality look into preg_replace

 

<?php
//str_replace example
//use str_ireplace for a case insensitive replace
$from_db = "This could be the string returned from your database";
$search_term = "string";//If the word 'string' was searched for
str_replace($search_term,'<strong>'.$search_term.'</strong>',$from_db);
echo $search_term;

 

Quick response and recommendation will take further work. It'll require a db table of words and implementation of ajax (usualy) for a list of optional search terms.

Link to comment
https://forums.phpfreaks.com/topic/144605-search-functionality/#findComment-758834
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.