Home >Topics >php mysql >How to query the name of mysql table in php

How to query the name of mysql table in php

coldplay.xixi
coldplay.xixiOriginal
2020-11-19 09:27:303253browse

How to query the name of mysql table in php: first connect to the server, the code is [die("Connection failed: " . mysql..]; then select the database, the code is [while($row = mysql_fetch_array($result ))】.

How to query the name of mysql table in php

Recommended (free): php mysql

How to query the name of mysql table in php:

<meta http-equiv=&#39;Content-Type&#39; content=&#39;text/html; charset=utf-8&#39; />
<?php 
$servername = "sdm163155241.com";
$username = "sdm1655241";
$password = "1746aaa;
// 连接服务器
$con = mysql_connect($servername, $username, $password);
if (!$con)
{
die("Connection failed: " . mysql_error());
}
// 选择数据库
$dbName = "sdm1631efee_db";
$db_selected = mysql_select_db($dbName, $con);
if (!$db_selected)
{
die ("Can\&#39;t DB sdm163155241_db : " . mysql_error());
}
$tabelCount = 1;
$result = mysql_query("SHOW TABLES"); 
if($result)
{
while($row = mysql_fetch_array($result)) 
{ 
echo $tabelCount.": ".$row[0]. "<br/>"; 
$tabelCount++;
} 
}else
{
echo "query result is null";
} 
mysql_free_result($result); 
mysql_close($con)
?>

The result is displayed as shown below:

How to query the name of mysql table in php

The above is the detailed content of How to query the name of mysql table in php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Related articles

See more