话不多说,请看代码: <?php $conn = mysql_connect('localhost','root','123456') or die('连接失败'); mysql_select_db('ecshop'); mysql_query('set names utf8'); $attr = isset($_GET['attr'])?$_GET['attr']:'is_hot'; //由html 的ajax提交过来 然后根据它来取数据~ $sql = 'select goods_name,goods_id,shop_price from goods where '.$