From c0f065e6bddad3c69fd802749608f05b9351ba4f Mon Sep 17 00:00:00 2001 From: "Johan \"Papa\" Cwiklinski" Date: Sat, 5 Jun 2010 21:52:47 +0200 Subject: Add autocompletion on master search ; closes #49 --- autocompleter.php | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 autocompleter.php (limited to 'autocompleter.php') diff --git a/autocompleter.php b/autocompleter.php new file mode 100644 index 0000000..e693e9a --- /dev/null +++ b/autocompleter.php @@ -0,0 +1,67 @@ +. + * + * @category Main + * @package RPMPHP + * + * @author Remi Collet + * @author Johan Cwiklinski + * @copyright 2010 Remi Collet + * @license http://www.gnu.org/licenses/agpl-3.0-standalone.html AGPL License 3.0 or (at your option) any later version + * @link http://github.com/remicollet/rpmphp/ + * @since The begining of times. +*/ +require 'main.inc.php'; + +$q = null; +$limit = null; +$ret = null; +if( !isset($_GET['q']) || $_GET['q'] == '' ) { + die(); +} else { + $q = $_GET['q']; + if( !isset($_GET['limit']) || $_GET['limit'] == '' ) { + $limit = 10; + } else { + $limit = $_GET['limit']; + } +} + +try { + $db = new PDO ("mysql:dbname=" . MYBASE . ";host=" . MYHOST, MYUSER, MYPASS); + + $sql = "SELECT name FROM rpm WHERE name LIKE '$q%' GROUP BY name LIMIT 0,$limit"; + + $resrpm = $db->query($sql); + + while ( $rpm = $resrpm->fetchObject() ) { + $ret .= $rpm->name . "\n"; + } +} catch(PDOException $e) { + echo 'An error occured.'; +} +echo $ret; +?> \ No newline at end of file -- cgit