PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

mysql_thread_id> <mysql_stat
Last updated: Fri, 27 Jun 2008

view this page in

mysql_tablename

(PHP 4, PHP 5, PECL mysql:1.0)

mysql_tablename — Ottiene il nome della tabella

Descrizione

string mysql_tablename ( resource $risultato , int $i )

mysql_tablename() prende il puntatore risultato dalla funzione mysql_list_tables() come un indice intero e restituisce il nome di una tabella. La funzione mysql_num_rows() può essere usata per determinare il numero di tabelle nel risultato puntatore. Usare la funzione mysql_tablename() per esplorare questo risultato puntatore o qualsiasi funzione per i risultati delle tabelle, come mysql_fetch_array().

Example #1 Esempio di mysql_tablename()

<?php
    mysql_connect
("localhost""utente_mysql""password_mysql");
    
$risultato mysql_list_tables("mio_db");

    for (
$i 0$i mysql_num_rows($risultato); $i++)
        
printf ("Tabela: %s\n"mysql_tablename($risultato$i));

    
mysql_free_result($risultato);
?>

Vedere anche: mysql_list_tables().



add a note add a note User Contributed Notes
mysql_tablename
Haseldow
23-Apr-2004 05:00
Another way to check if a table exists:

if(mysql_num_rows(mysql_query("SHOW TABLES LIKE '".$table."'"))==1) echo "Table exists";
else echo "Table does not exist";
pl at thinkmetrics dot com
17-Dec-2003 08:00
A simple function to check for the existance of a table:

function TableExists($tablename, $db) {
   
    // Get a list of tables contained within the database.
    $result = mysql_list_tables($db);
    $rcount = mysql_num_rows($result);

    // Check each in list for a match.
    for ($i=0;$i<$rcount;$i++) {
        if (mysql_tablename($result, $i)==$tablename) return true;
    }
    return false;
}

mysql_thread_id> <mysql_stat
Last updated: Fri, 27 Jun 2008
 
 
show source | credits | stats | sitemap | contact | advertising | mirror sites