基于jQuery的自动完成插件(2)


<?php
class DataFetch{
private $conn, $rs;
function __construct(){
$this->conn = mysql_connect("localhost","root","pwd") or die("Cant't connect host~");
mysql_select_db("studentinfo",$this->conn) or die("Cant't select database~");
}
public function data_list($s){
$this->rs=mysql_query("select sno from student where sno like '$s%'") or die("Can't fetch~");
$dataList=array();
while($row = mysql_fetch_array($this->rs,MYSQL_ASSOC)){
array_push($dataList,$row);
}
return $dataList;
}
}
$search= isset($argv[1]) ? $argv[1] :
( isset($_GET['search']) ? $_GET['search'] : '' ) ;
$fetch=new DataFetch();
$data=$fetch->data_list($search);
echo '[';
foreach ($data as $key=>$value){
echo "\n\t";
echo '"'.$value['sno'].'"';
if( $key!=count($data)-1 ) echo ','; else echo "\n";
}
echo "]\n";
?>

您可能感兴趣的文章:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wdffzd.html