我正在尝试计算单个表中的总行数。只需要知道总共有多少行,没有别的。我正在使用Oracle数据库。
我试过了
$sql = "SELECT COUNT(*) AS homes FROM homes";
但我不确定如何显示结果。
答案 0 :(得分:0)
$sql = "SELECT COUNT(*) AS count FROM homes";
答案 1 :(得分:0)
<?php
$link = mysqli_connect("host", "username", "password");
mysqli_select_db("database", $link);
$result = mysqli_query("SELECT * FROM homes", $link);
$num_rows = mysqli_num_rows($result);
echo "$num_rows Rows\n";
?>
答案 2 :(得分:0)
从
计算行数 $sql = "SELECT * FROM homes"; // fetch the rows
$sql1=mysql_query($sql);
$count=mysql_num_rows($sql1) // count number of rows in table
echo $count; //$count has the value of rows in table..
答案 3 :(得分:0)
使用此代码:
//代码在这里
<?php
$sql = "SELECT COUNT(*) AS homes FROM homes";
$result = mysqli_query($sql);
$row = mysqli_fetch_array($result);
print($row['homes']); // prints count
?>