|
|
|
คำสั่ง PHP, MySQLที่ใช้แสดงรายชื่อฐานข้อมูล show database ทั้งหมดคือคำสั่งอะไร |
|
|
|
|
|
|
|
Code (PHP MySQL Show Database)
<?
$objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database");
$objQuery = mysql_query("show databases;");
while($objResult = mysql_fetch_array($objQuery))
{
echo $objResult["Database"]."<br>";
}
mysql_close($objConnect);
?>
|
|
|
|
|
Date :
2012-02-17 15:30:45 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
อันนี Show Table ครับ
Code (PHP MySQL Show Table Name)
<?php
$dbname = 'mydatabase';
if (!mysql_connect('localhost', 'root', 'root')) {
echo 'Could not connect to mysql';
exit;
}
$sql = "SHOW TABLES FROM $dbname";
$result = mysql_query($sql);
if (!$result) {
echo "DB Error, could not list tables<br>";
echo 'MySQL Error: ' . mysql_error();
exit;
}
while ($row = mysql_fetch_row($result)) {
echo "Table: {$row[0]}<br>";
}
mysql_free_result($result);
?>
|
|
|
|
|
Date :
2012-02-17 15:32:16 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|