Autocomplete using php mysql jquery on dynamic search form -
Autocomplete using php mysql jquery on dynamic search form -
i'm busy building search class have intergrate/add autocomplete using jquery... due lack of time not sure how address, plus i'm new autocomplete - @ to the lowest degree on level of functionality...
here form:
<form action="'.$_server['request_uri'].'" method="post"> <input type="text" id="suggest" name="searchthis" title="search something" value="" size="14" /> <select name="searchitems"> <optgroup value="vehicles" label="vehicles">vehicles <option value="vehicles.make">make</option> <option value="vehicles.model">model</option> <option value="vehicles.regnumber">registration number</option> <option value="vehicles.licenseexpiredate">license expire date</option> </optgroup> <optgroup value="owners" label="owners">clients <option value="owners.ownername" label="" >name</option> <option value="owners.mobile">mobile number</option> <!-- <option value="owner_id"> </option> --> </optgroup> <!-- <optgroup value="users">users <option value=""> </option> <option value=""> </option> <option value=""> </option> </option> </optgroup>--> </select> <input type="submit" name="search" value="search" /> </form> <ul id="suggestions"> </ul>
here search implementation
//item searched $srchthis = strip_tags(trim($searchthis)); //[0]= table , [1]=field search $srchstack = explode('.',$field); $gtdata = "select * '{$srchstack[0]}' {$srchstack[1]} '%{$srchthis}%' or "; //or die(mysqli_error($_session['mysqldbcxn'])) if(!$selectc = mysqli_query($_session['mysqldbcxn'],"select * {$srchstack[0]} {$srchstack[1]} '{$srchthis}%' or {$srchstack[1]} '%{$srchthis}%'")) { //$gtdata $show .= "no entry characters or name:<br>".mysqli_error($_session['mysqldbcxn']); $this->searchform = $show; } else { //$srchdata = array(); if(!$srchdata = mysqli_fetch_assoc($selectc)) { //, mysql_assoc)) { $show .= "there error here: select * {$srchstack[0]} {$srchstack[1]} '{$srchthis}%' or {$srchstack[1]} '%{$srchthis}%'".mysqli_error($_session['mysqldbcxn']); $this->searchform = $show; homecoming $this->searchform = 'background'.$show; } else { //echo var_dump($srchdata); $show .= ' <table id="searchtable" border="0" width="380px" style="border:2px solid #0000;">'; foreach($srchdata $fields=>$data) { if($srchstack[0] == 'vehicles' && $fields == 'regnumber') { $dataitem = $data; $edittbl = 'vehicles'; } elseif($srchstack[0] == 'owners' && $fields == 'owner_id') { $dataitem = $data; $edittbl = 'owners'; } elseif($srchstack[0] == 'users' && $fields == 'username') { $dataitem = $data; $edittbl = 'users'; } $show .= '<tr><td>'.$fields.'</td><td>'.$data.'</td></tr>'; } $show .= '<tr style="background-color:rgb(204,0,0); text-align:center; color:#000; font-weight:bold"><td> <a href="index.php?action=edit'.$edittbl.'&&tbl='.$srchstack[0].'&&item='.$dataitem.'">update</a></td><td> <a href="index.php?action=delete&&tbl='.$srchstack[0].'&&item='.$dataitem.'">delete</a></td></tr> </table>'; homecoming $this->searchform = $show;
any sugguestion's on how implement jquery???
php jquery mysql autocomplete
Comments
Post a Comment