/****************************************************************/
/*
CREATE TABLE `mestests` (
`uid` BIGINT( 10 ) NOT NULL AUTO_INCREMENT ,
`lastname` VARCHAR( 50 ) NOT NULL ,
`firstname` VARCHAR( 50 ) NOT NULL ,
`address` VARCHAR( 100 ) NOT NULL ,
INDEX ( `uid` )
);
*/
/****************************************************************/
$link = @mysql_connect('localhost', 'root', '');
if (!$link) {
die('Could not connect to MySQL server: ' . mysql_error());
}
$dbname = 'test';
$tablename = 'mestests';
$db_selected = mysql_select_db($dbname, $link);
if (!$db_selected) {
die("Could not set $dbname: " . mysql_error());
}
$res = mysql_query('select * from '.$tablename, $link);
echo mysql_field_name($res, 0) . "
\n"; // retourne uid
echo mysql_field_name($res, 1) . "
\n"; // retourne lastname
echo mysql_field_name($res, 2); // retourne firstname
echo "
";
$result = mysql_list_tables($dbname);
$num_rows = mysql_num_rows($result);
for ($i = 0; $i < $num_rows; $i++) {
echo "Table: ", mysql_tablename($result, $i), "
\n";
}
mysql_free_result($result);
?>