counting tables

Hi,

I'm using PHP 4.4.4 with MySQL 5.0. Given my db connection info, how
would I figure out how many tables were in the selected db?

Thanks, - Dave
laredotornado [ Mo, 14 Mai 2007 23:46 ] [ ID #1711870 ]

Re: counting tables

laredotornado [at] zipmail.com wrote:
> Hi,
>
> I'm using PHP 4.4.4 with MySQL 5.0. Given my db connection info, how
> would I figure out how many tables were in the selected db?

http:/www.php.net/manual/en/function.mysql-list-tables.php

--

//Aho
Shion [ Di, 15 Mai 2007 05:48 ] [ ID #1712601 ]

Re: counting tables

laredotornado [at] zipmail.com wrote:
> Hi,
>
> I'm using PHP 4.4.4 with MySQL 5.0. Given my db connection info, how
> would I figure out how many tables were in the selected db?
>
> Thanks, - Dave
>

One way, maybe others that are better?

<?php
mysql_connect("localhost", "<user>", "<pass>");
mysql_select_db("<database>");
$sql = "SHOW TABLES;";
$ds = mysql_query( $sql );
echo mysql_num_rows( $ds );
mysql_free_result( $ds );
?>
Tyno Gendo [ Di, 15 Mai 2007 10:42 ] [ ID #1712603 ]

Re: counting tables

<laredotornado [at] zipmail.com> wrote in message
news:1179179200.148304.182970 [at] p77g2000hsh.googlegroups.com.. .
> Hi,
>
> I'm using PHP 4.4.4 with MySQL 5.0. Given my db connection info, how
> would I figure out how many tables were in the selected db?
>
> Thanks, - Dave
>

With MySQL I think you can run a query like "show tables;" and should be
able to get a count from those results.

Tom
--
Newsguy.com - Express Accounts - 30 GB $9.95 / month
tom [ Di, 15 Mai 2007 19:17 ] [ ID #1712610 ]
PHP » alt.php.sql » counting tables

Vorheriges Thema: Count() multiple columns
Nächstes Thema: SQL question - linking and gor