adund cn adund cn - 2 months ago 7
MySQL Question

How to show array from show table schema query in php

i have a query

$qdrop=mysqli_query($connect,"select TABLE_NAME,create_time
FROM INFORMATION_SCHEMA.TABLES
WHERE table_schema = 'purbalingga'
AND CREATE_TIME <='2016-10-07' and TABLE_NAME LIKE '2016%'");


and a while for show the array

while ($datadrop=mysqli_fetch_array($qdrop)) {
echo $qdrop['TABLE_NAME'];echo"<br/>";
}


But i got an error:

Fatal error: Cannot use object of type mysqli_result as array in E:\xampp\htdocs

Answer

Replace:

while ($datadrop=mysqli_fetch_array($qdrop)) {
  echo $qdrop['TABLE_NAME'];
  echo"<br/>";
}

With:

while ($datadrop=mysqli_fetch_array($qdrop)) {
  echo $datadrop['TABLE_NAME'];
  echo"<br/>";
}

$qdrop only holds the query but $datadrop is the one holding the result in array.