我想讓PHP給我一些統計數據在我的參與者列表中。我需要知道每個聯盟有多少人每個聯盟(從) 如果您不知道所有聯盟和職位,有沒有簡單的方法可以做到這一點?Php數據庫信息排序
<?php
include 'includes/config.php';
$sql="SELECT * FROM participants ORDER BY `from`, `status`";
$self = mysql_query($sql);
echo "<table><tr><th>Name</th><th>Affiliation</th><th>Status</th></tr>";
while ($row = mysql_fetch_array($self)) {
echo "<tr><td>".$row['name']."</td><td>".$row['from']."</td><td>".$row['status']."</td></tr>";
}
echo "</table>";
?>
數據庫的結構是 Name - Affiliation - Status
所以大家誰寄存器將被放置在像 Bob - Minnesota University - Phd Student
現在我希望所有的從屬關係的列表,每個聯繫我需要一個列表所有的stati和多少人分享他們。
所以像: Minnesota University Phd Student: 5 Professor: 12 Bachelor Student: 4 Caltech Phd Student: 1 Professor: 14 Bachelor Student:32
你能澄清更好一點,你需要什麼?也許提供你的表格結構和樣本數據? –
如果您設置了[SQL小提琴](http://sqlfiddle.com/) –
,那麼我們可以幫助您更輕鬆地發佈includes/config.php文件嗎? – Daan