2011-12-18 98 views

回答

7

您可以直接從information_schema數據庫查詢表名。假設你的數據庫名稱是在變量$your_database_name

mysql_select_db("information_schema"); 
$sql = "SELECT TABLE_NAME 
    FROM TABLE 
    WHERE 
    TABLE_SCHEMA = '$your_database_name' 
    AND TABLE_NAME NOT IN ('users','cars','gifts')"; 
1

如果你不想顯示錶,然後同時echo,你可以這樣做:

while($row = mysql_fetch_array($res)) 
{ 
    if($row[0] == 'users' || $row[0] == 'cars' || $row[0] == 'gifts') 
     continue; 
    else 
     echo $row[0]; 
} 
2
SHOW TABLES FROM database_name WHERE tables_in_database_name NOT IN ('users'); 

如果你既不想汽車用戶

SHOW TABLES FROM database_name WHERE tables_in_database_name NOT IN ('users', 'cars');