问答详情
源自:3-3 获取分页数据

这段代码到底那里有错呢。

<?php

$page= $_GET['P'];

$host = "qdm165278190.my3w.com";

$username = "qdm165278190";

$password = "liyigang889897";

$db="qdm165278190_db";

$conn = mysqli_connect($host,$username,$password);

if(!$conn){

    echo "数据库连接失败";

    exit;

}

mysqli_select_db($db);

mysqli_query ("SET NAMES UTF8");

$sql = "select * from tdb_goods limit " .($page-1)*10 . ",10";

$result = mysqli_query($sql);

while($row = mysql_fetch_assoc($result)){

    echo $row['goods_name'].'_'.$row['goods_cate'].'<br>';

}


提问者:qq_初夏风_0 2017-03-08 23:37

个回答

  • qq_看看不懂_0
    2017-03-09 09:25:30

    mysqli不是这样用的,

    $conn = new mysqli($host,$username,$password,$db);

    $result = $conn -> query($sql);

    用面向对象的方式写