电脑安全

您当前的位置:主页 > 电脑安全 >

php+ajax 仿google 下拉框代码一-网络编程

来源:[db:来源]标题:   代码    编辑:电脑技术全能网 时间:2019-09-19 06:21

原标题:php+ajax 仿google 下拉框代码一-网络编程
   php+ajax 仿google 下拉框代码一,这里php代码<?phpheader('Content-Type:text/html;charset=utf-8');require('../../admin/include/db_conf.php');if($_POST['add']){ $keyword = trim($_POST['keyword']); if(empty($keyword)){ header("LOCATION: suggest.html"); exit; } $db = db_connect(); $db->query("set names 'gb2312'"); $sql = "select*from suggest where keyword = '$keyword'"; if($db->query($sql)->num_rows>0){ header("LOCATION: suggest.html"); exit; } $num = rand(15, 2008); $sql = "insert into suggest values(NULL, '$keyword', $num)"; $db->query($sql); $db = NULL; header("LOCATION: suggest.html"); exit;}$keyword = $_POST['keyword'];if(empty($keyword)){ echo 'null'; exit;}$db = db_connect();$db->query("set names 'utf8'");$sql = "select *from suggest where keyword REGEXP '^$keyword' order by id desc limit 0, 15";$result = $db->query($sql);if($result->num_rows<1){ echo 'null'; exit;}$arr = array();while($rows=$result->fetch_object()){ $keyword = $rows->keyword; $arr[]="['$keyword', '$rows->num ".iconv('gb2312','utf-8','成果')."']";}$arr = '['.implode(',',$arr).']';echo $arr;?>

上一篇:zend studio for eclipse的ssh使用rsa-网络编程

下一篇:没有了