try using mysql_num_rows. e.g.
Code:
$query = mysql_query("SELECT * FROM table");
$number=mysql_num_rows($query);
and incorporate that with this: http://www.ebrueggeman.com/blog/mysq...bles-in-mysql/
Edit: added code:
PHP Code:
/* fill in your database name */
$database_name = "my_db";
$number=0;
/* connect to MySQL */
if (!$link = mysql_connect("db_host_name", "username", "pass")) {
die("Could not connect: " . mysql_error());
}
/* query all tables */
$sql = "SHOW TABLES FROM $database_name";
if($result = mysql_query($sql)){
/* add table name to array */
while($row = mysql_fetch_row($result)){
$found_tables[]=$row[0];
}
}
else{
die("Error, could not list tables. MySQL Error: " . mysql_error());
}
/* loop through and drop each table */
foreach($found_tables as $table_name){
$sql = "SELECT * FROM $database_name.$table_name";
if($result = mysql_query($sql)){
$number+=mysql_num_rows($result);
}
else{
echo "Error finding rows in $table_name. MySQL Error: " . mysql_error() . "";
}
}
Bookmarks