<?php header('content-type:text/html;charset=utf-8'); mysql_connect('localhost', 'root' ,''); mysql_select_db("test"); mysql_query("set names utf8"); $querystring = $_post['querystring']; if(strlen($querystring) >0) { $sql= "select value from countries where value like '".$querystring."%' limit 10"; $query = mysql_query($sql); while ($result = mysql_fetch_array($query,mysql_both)){ $value=$result['value']; ?> <li onclick="fill('<?=$value?>')"><?=$value?></li> <?php } } ?>
thinkphp中已经有封装好的函数可以用
public function query(){ $where = array(); $limit = 10; if(strlen($queryString)>0){ $where['value'] = array('like','%'.$queryString.'%'); } $list = M('test')->where($where)->limit($limit)->select(); //todo }
public function query(){ $where = array(); $limit = 10; if(strlen($queryString)>0){ $where['value'] = array('like','%'.$queryString.'%'); } $list = M('countries')->field('value')->where($where)->limit($limit)->select(); //todo }
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号