In questo tutorial imparerete come creare un layout/descrizione del vostro database MySQL in formato XML.
Se sei un beginner in XML, ti consigliamo di leggere prima una guida XML e poi di riprendere questa!

 
< ?php
$host = ‘localhost’;
$user = ‘tuouser’;
$pass = ‘tuapass’;
$db = ‘tuodb’;
 
// Connect to the MySQL server
$link = mysql_connect($host,$user,$pass);
if ($link){
// Select the database
mysql_selectdb($db,$link);
 
// Write xml header information
echo htmlspecialchars(
);
echo "";
 
// Get all tables
$result = mysql_query(‘SHOW TABLES’);
while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
// Get table name
$table = $row***91;0***93; ;
 
// Get table info
$struct = mysql_query(‘DESCRIBE ‘.$table);
 
// Write table info
echo "&nbsp;&nbsp;&nbsp;"
.htmlspecialchars(
)."";
 
// Get table description
while ($row2 = mysql_fetch_array($struct, MYSQL_NUM)) {
$autoi = (strstr($row2***91;5***93;,‘auto_increment’)) ? ‘true’ : ‘false’;
echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
echo htmlspecialchars()."";
}
 
// Write table section close element
echo "&nbsp;&nbsp;&nbsp;"
.htmlspecialchars(
 
)."";
 
}
 
// Write the final close element
echo htmlspecialchars()."";
}
 
?>
 

Share on FacebookCondividi su facebook

fonte: www.sastgroup.com