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, 18 Jul 2008

view this page in

mysql_tablename

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

mysql_tablename — Devuelve el nombre de la tabla de un campo

Descripción

cadena mysql_tablename ( int $id_resultado , int $i )

mysql_tablename() toma un puntero de resultado devuelto por mysql_list_tables() así como un índice (integer) y devuelve el nombre de una tabla. Se puede usar la función mysql_num_rows() para determinar el número de tablas en el puntero de resultado. Use la función mysql_tablename() para usar este apuntador de resultado, o cualquier función para las tablas resultantes como mysql_fetch_array().

Example #1 Ejemplo mysql_tablename

<?php
mysql_connect
("localhost""mysql_user""mysql_password");
$result mysql_list_tables("mydb");

$num_rows mysql_num_rows($result);
for (
$i 0$i $num_rows$i++) {
    echo 
"Table: "mysql_tablename($result$i), "\n";
}

mysql_free_result($result);
?>

Vea también mysql_list_tables(), mysql_field_table(), mysql_db_name().



add a note add a note User Contributed Notes
mysql_tablename
Haseldow
23-Apr-2004 02: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 05: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, 18 Jul 2008
 
 
show source | credits | sitemap | contact | advertising | mirror sites