Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Sql获取值_Php_Mysql - Fatal编程技术网

Php Sql获取值

Php Sql获取值,php,mysql,Php,Mysql,我正在做一些数据库查询,我想要一个自动系统,但在使用查询获取表列表时会遇到这种情况 SHOW TABLES ; 使用Php来获取这个函数,现在只返回表数组中的值,比如Person。 有可能只得到结果吗 $rows = Array(); while($row = mysql_fetch_array($result)){ array_push($rows, $row); } echo json_encode($rows); 结果 [{"0":"Company","Tables_in_d

我正在做一些数据库查询,我想要一个自动系统,但在使用查询获取表列表时会遇到这种情况

SHOW TABLES ;
使用Php来获取这个函数,现在只返回表数组中的值,比如Person。 有可能只得到结果吗

   $rows = Array();
while($row = mysql_fetch_array($result)){
  array_push($rows, $row);
}
echo json_encode($rows);
结果

[{"0":"Company","Tables_in_database":"Company"},{"0":"Education","Tables_in_database":"Education"},{"0":"Health","Tables_in_database":"Health"},{"0":"Person","Tables_in_database":"Person"},{"0":"Personal","Tables_in_database":"Personal"},{"0":"Skill","Tables_in_database":"Skill"}]

我只想要值:公司、教育、健康等。

$row
是一个数组,包含结果中的所有列。因为您只需要一列,所以请显式选择它

array_push($rows, $row['Tables_in_database']);

$row
是一个数组,包含结果中的所有列。因为您只需要一列,所以请显式选择它

array_push($rows, $row['Tables_in_database']);

我不明白你的问题。你到底想要什么?我也不明白!如果可以,你应该这样做。已在PHP7中删除。了解使用PDO的语句,并考虑使用PDO。感谢回复
array_push($rows,$row['Tables_in_database'])?我不明白你的问题。你到底想要什么?我也不明白!如果可以,你应该这样做。已在PHP7中删除。了解使用PDO的语句,并考虑使用PDO。感谢回复
array_push($rows,$row['Tables_in_database'])