$sql="SELECT count(at) as web, count(at) as fb, count(at) as mb, today_insert FROM tb_tb WHERE year (`today_insert`) = '2011' and (month(`today_insert`) = '09') GROUP BY year (`today_insert`) = '2011' and (month(`today_insert`) = '09') ORDER BY counta
<?php
include "config.php";
$sql="SELECT COUNT(at) AS web FROM tb WHERE at='web' and year (`today_insert`) = '2011' and (month(`today_insert`) = '09') GROUP BY year (`today_insert`) = '2011' and (month(`today_insert`) = '09') ORDER BY counta desc";
$result =mysql_query($sql);
mysql_close();
while($mydata = mysql_fetch_array($result))
{
$web="{$mydata['web']}";
echo "$web";
}
?>
<?php
include "config.php";
$sql="SELECT COUNT(at) AS fb FROM tb WHERE at='fb' and year (`today_insert`) = '2011' and (month(`today_insert`) = '09') GROUP BY year (`today_insert`) = '2011' and (month(`today_insert`) = '09') ORDER BY counta desc";
$result =mysql_query($sql);
mysql_close();
while($mydata = mysql_fetch_array($result))
{
$fb="{$mydata['fb']}";
echo "$fb";
}
?>
<?php
include "config.php";
$sql="SELECT COUNT(at) AS mb FROM tb WHERE at='mb' and year (`today_insert`) = '2011' and (month(`today_insert`) = '09') GROUP BY year (`today_insert`) = '2011' and (month(`today_insert`) = '09') ORDER BY counta desc";
$result =mysql_query($sql);
mysql_close();
while($mydata = mysql_fetch_array($result))
{
$mb="{$mydata['mb']}";
echo "$mb";
}
?>
SELECT
tb_tb.at,
Count(tb_tb.at AS count_at
FROM
tb_tb
GROUP BY
tb_tb.at
Code (PHP)
SELECT
SUM(IF(q1.count_at = "fb", q1.count_at,0)) AS `fb`,
SUM(IF(q1.count_at = "mb", q1.count_at,0)) AS `mb`,
SUM(IF(q1.count_at = "web", q1.count_at,0)) AS `web`
FROM
(SELECT tb_tb.at, Count(tb_tb.at) AS count_at FROM tb_tb GROUP BY tb_tb.at) as q1