phpFunctions
Search:
Matches:
Description:
Usage:
Version:
Manual:
/* Hello, if possible link to phpfunctions.nfshost.com if you use this source and share your own source. No real binding license though. Requires a DB with this structure: //START STRUCTURE CREATE TABLE functions ( id int(11) NOT NULL auto_increment, manual text NOT NULL, name text NOT NULL, description text NOT NULL, use1 text NOT NULL, version text NOT NULL, searcher text NOT NULL, KEY id (id) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; //END STRUCTURE Full dump available at phpfunctions.nfshost.com */ if (isset($_GET['search'])) //If its asking for the AJAX response { $link = mysql_connect('[[[DB ADDRESS]]]', '[[DB USERNAME]]', '[[DB PASSWORD]]'); //Connect to DB if (!$link) { die('Not connected : '); //CHECK FOR CONNECTION, else die } $db_selected = mysql_select_db('[[[DB NAME]]]', $link); //Select name if (!$db_selected) { die ('Can\'t select DB' ); //Die if no DB of that name } $searchterm=strtolower($_GET['search']); //Everything lowercase, DB needs to be the same $searchterm = str_replace("_","\_",$searchterm); //Format underscores correctly for LIKE, otherwise _ = any character $searchterm3=str_replace("\_","",$searchterm);//This is specifically for PHP, incase people miss out underscores $sql="(SELECT * FROM functions WHERE name LIKE '$searchterm%' ORDER BY name) UNION (SELECT * FROM functions WHERE name LIKE '%$searchterm%' ORDER BY name) UNION (SELECT * FROM functions WHERE searcher LIKE '%$searchterm3%' ORDER BY name) LIMIT 5"; //Gets firstly whattheytyped???????? //Then ??????whattheytyped????? //Then ?????w_hat_theyt_yped???? (for PHP, using searcher which is a different field without underscores) $result=mysql_query($sql); //Do query $i=1; //Define $i while($row=mysql_fetch_assoc($result)) //Get row til end { ?> = $row['name'] ?>, $i++; //Increment for HTML } die(); //Die so HTML below isn't outputted } echo ''; //Echo it, cos otherwise it gets confused with , its almost valid XHTML apart from autocomplete ?>
Search:
Matches:
Description:
Usage:
Version:
Manual: