(localhost), . , UNION , SUM(), .
SELECT SUM(postcounts) AS total
FROM (
SELECT COUNT(postId) AS postcounts FROM mydb1.my_table
UNION ALL
SELECT COUNT(postId) AS postcounts FROM mydb2.my_table
) allposts
, mysql_num_rows() 1, , - COUNT(postIdD). , .
, , , $result, total:
if ($result) {
$row = mysql_fetch_assoc($result);
echo $row['total'];
}
:
$db1 = mysql_connect($connection,$username,$password) or die(mysql_error());
mysql_select_db($database1, $db1);
$query = "
SELECT SUM(postcounts) AS total
FROM (
SELECT COUNT(postId) AS postcounts FROM mydb1.my_table
UNION ALL
SELECT COUNT(postId) AS postcounts FROM mydb2.my_table
) allposts ";
$result = mysql_query($query, $db1);
if ($result) {
$row = mysql_fetch_assoc($result);
echo $row['total'];
}