這個(gè)需要查詢 information_schema.TABLES. 其中的 data_length 就是你要的...
創(chuàng)新互聯(lián)公司專業(yè)為企業(yè)提供宿豫網(wǎng)站建設(shè)、宿豫做網(wǎng)站、宿豫網(wǎng)站設(shè)計(jì)、宿豫網(wǎng)站制作等企業(yè)網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計(jì)與制作、宿豫企業(yè)網(wǎng)站模板建站服務(wù),10余年宿豫做網(wǎng)站經(jīng)驗(yàn),不只是建網(wǎng)站,更提供有價(jià)值的思路和整體網(wǎng)絡(luò)服務(wù)。
給你個(gè)查詢數(shù)據(jù)庫大小的語句.
select concat(round(sum(DATA_LENGTH/1024/1024),2), ' M') as dbsize from information_schema.TABLES where table_schema= 'mysql';
價(jià)格 where 條件就可以指定單個(gè)表了.
select concat(round(sum(DATA_LENGTH/1024/1024),2), ' M') as dbsize from information_schema.TABLES where table_schema= 'mysql' and table_name='user';
mysql_connect("localhost","root","123456") or
die("打開數(shù)據(jù)庫服務(wù)器失?。?); //連接數(shù)據(jù)庫
mysql_select_db("a") or
die("打開數(shù)據(jù)庫a失?。?); //打開數(shù)據(jù)庫,a為數(shù)據(jù)庫名
$sql = "select id from b"; //id為字段名,b為表名
$result=mysql_query($sql);
if(mysql_query($sql)) //判斷$sql語句是否執(zhí)行
{
$num=mysql_num_rows($result); //取得包含id字段記錄的行數(shù)
echo "一共有".$num."個(gè)id"; }思想就是:根據(jù)含有ID的記錄(數(shù)據(jù)庫里一行內(nèi)容稱為一條記錄)條數(shù)來確定ID的個(gè)數(shù)
先從數(shù)據(jù)庫獲取到相應(yīng)表里的價(jià)錢字段的數(shù)據(jù),然后遍歷拿到的數(shù)據(jù),求和
$sql?=?'select?price?from?table';
//連接數(shù)據(jù)庫,?執(zhí)行sql語句,?return查詢的結(jié)果$rs
for?($i?=?0,?$sum?=?0;?$i??count($rs);?$i++){
$sum?+=?$rs[$i];
}
用sql group by 下就可以實(shí)現(xiàn)
select?count(*)?as?count,FROM_UNIXTIME(addtime,'%m')?from?download?where?FROM_UNIXTIME(addtime,'%Y')?=?'2014'?group?by?FROM_UNIXTIME(addtime,'%m')?
//運(yùn)行結(jié)果
/*
總和????月份
76 01
99 02
95 03
172 04
234 05
153 06
52 07
*/
select?uid,?sum(money)?as?money_total?from?cm_tables?group?by?uid?order?by?money_total?desc;
需要準(zhǔn)備的材料分別是:電腦、php編輯器、瀏覽器。
1、首先,打開php編輯器,新建php文件,例如:index.php。
2、在index.php中,輸入代碼:
$conn = new mysqli('10.5.15.177', 'root', '', 'test');
$sql = "select * from stu";
$r = $conn-query($sql);
print_r($r-num_rows);
3、瀏覽器運(yùn)行index.php頁面,此時(shí)打印出了stu表的記錄數(shù)是5。
本文標(biāo)題:php網(wǎng)頁表格數(shù)據(jù)統(tǒng)計(jì) php 數(shù)據(jù)分析報(bào)表
標(biāo)題來源:http://chinadenli.net/article36/doddgpg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供域名注冊、網(wǎng)站改版、網(wǎng)站導(dǎo)航、建站公司、網(wǎng)站維護(hù)、手機(jī)網(wǎng)站建設(shè)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)