Hi.

The simple way is use "SHOW TABLE STATUS FROM DATABASE_NAME" Like this in
php script (you also put this SQL into any application that you need)

<?php
$conn=@mysql_connect ("localhost", "root", "")  or die ("Can't connect to
MySQLserver");
$rs=@mysql_query("SHOW TABLE STATUS FROM Some_database") or
die(mysql_error());
$nrow= mysql_num_rows($rs);
echo "<table border=1 cellspacing=0><tr align=center bgcolor=skyblue>";
echo "<td>Table name</td><td>Records</td></tr>";
while ($row=mysql_fetch_array($rs)) {
          echo "<tr><td>",$row['Name'],"</td><td
align=right>",number_format($row['Rows']),"</td></tr>";
 }
echo "</table>";
mysql_close ($conn);
?>

you will see the result in table (tag html) format with the name of data
table and it's number of records.


Kittiphum  Worachat,M.T.
www.hatyailab.com

----- Original Message -----
From: "Doug Bishop" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Thursday, April 04, 2002 1:12 PM
Subject: RE: Table statistics


> Try:
>
> <?
> mysql_connect("localhost", "user", "password");
> $query = "SHOW TABLES;";
> $result = mysql_db_query("databasename", $query);
> $i = 0;
> while ($row = mysql_fetch_array($result))
> {
>     $tableNames[$i] = $row[0];
> $i++;
> }
> for ($i = 0; $i <= count($tableNames); $i++)
> {
> $query = "SELECT COUNT(*) FROM " . $tableNames[$i] . ";";
> $result = mysql_db_query("databasename", $query);
> $row = mysql_fetch_array($result);
> echo "Table " . $tableNames[$i] . " contains " . $row[0] . " rows.\n<br>";
> }
> ?>
>
> Doug
>
> -----Original Message-----
> From: andy thomas [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, April 03, 2002 11:23 PM
> To: [EMAIL PROTECTED]
> Subject: Table statistics
>
>
> Is there a command I can give in the mysql client to find the number of
> rows in a table or, better still, the number of rows in all the tables in
> a database?
>
> Andy
>
>
> ---------------------------------------------------------------------
> Before posting, please check:
>    http://www.mysql.com/manual.php   (the manual)
>    http://lists.mysql.com/           (the list archive)
>
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail
<[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
>
>
>
> ---------------------------------------------------------------------
> Before posting, please check:
>    http://www.mysql.com/manual.php   (the manual)
>    http://lists.mysql.com/           (the list archive)
>
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail
<[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to