1
我正在做一些数据库查询,我想要一个自动系统,但是在使用查询获取表的列表时遇到此问题。Php Sql获取值
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"}]
我只希望值:公司,教育,健康等
我不明白你的问题。你到底想要什么? –
我也不明白! – Shadow
如果可以,你应该[停止使用'mysql_ *'函数](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php)。 [这些扩展](http://php.net/manual/en/migration70.removed-exts-sapis.php)已在PHP 7中删除。了解[编写](http://en.wikipedia.org/ wiki/Prepared_statement)语句[PDO](http://php.net/manual/en/pdo.prepared-statements.php)和[MySQLi](http://php.net/manual/en/mysqli.quickstart .prepared-statements.php)并考虑使用PDO,[它确实不难](http://jayblanchard.net/demystifying_php_pdo.html)。 –