I used to working on Oracle DB with PHP.
$strSQL = oci_parse($c1, "SELECT * FROM tb_users");
oci_execute($strSQL);
$Num_Rows = oci_fetch_all($strSQL, $dData);
That above code is working OK. I can get total rows and show the data using variable $dData[]
And now I'm using mySQL DB with PHP.
$strSQL = mysqli_query($c1, "SELECT * FROM tb_users");
$Num_Rows = mysqli_fetch_all($strSQL, $dData);
When I try to run the code (mySQL), the value of $Num_Rows is empty (I'm sure there is an data on db). And the data is not show using $dData
.
My question, is mysqli_fetch_all
correct? Or is there another way?
$strSQL = mysqli_query($c1, "SELECT * FROM tb_users");
$Num_Rows = mysqli_fetch_all($strSQL, $dData);
if you use loop then it will give result for individual record
while($Num_Rows = mysqli_fetch_all($strSQL, $dData)){
print_r($Num_Rows);
}
if you want number of rows then just
$num_rows=count($Num_Rows)
OR Use
mysqli_num_rows
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.