0

只有当我的数据库中“click”行中的数字小于 10 时,我才尝试使函数起作用。这就是我现在所拥有的:我将 echo 放在那里只是为了查看条件是否有效或不是。

<?php
include'connect.php';

$result = mysqli_query($con,"SELECT id, link_name, click  FROM clicks");

while($row = mysqli_fetch_array($result))
{
if ($row['click'] < 10) {
    echo $row['id'] . " " . $row['link_name']. " " .$row['click'];
echo "<br>";
}
}

mysqli_close($con);
?>
4

2 回答 2

2

try;

$result = mysqli_query($con,"SELECT id, link_name, click  FROM clicks WHERE click<10");

while($row = mysqli_fetch_array($result))
{
    echo $row['id'] . " " . $row['link_name']. " " .$row['click'];
    echo "<br>";
}

mysqli_close($con);
?>
于 2013-08-28T19:16:24.517 回答
1

为什么不在查询中使用 where 子句?

$result = mysqli_query($con,"SELECT id, link_name, click  FROM clicks
where click <10");
于 2013-08-28T19:15:10.583 回答