此代碼效果很好,但我在如何訂購時遺失了。在點數後對結果進行排序PHP
輸出示例:
撞擊3是Mozilla Firefox
撞擊2谷歌瀏覽器
撞擊4的Internet Explorer
撞擊2 Apple Safari中
命中1歌劇
$result = mysql_query("SELECT * FROM WEB_STATS WHERE real_user NOT LIKE 'Bot'");
$duplicates = array();
while($row = mysql_fetch_array($result)) {
$results = $row['user_browser'];
if (!array_key_exists($results, $duplicates)) {
$browsersLive[] = $results;
$duplicates[$results] = 1; ## mark that we've already output this records
}
}
foreach($browsersLive as $browserswive){
$query = "SELECT COUNT(*) FROM WEB_STATS WHERE user_browser = '$browserswive'";
$result = mysql_query($query) or die("Sorry, didn't work" . mysql_error());
$browser_count = mysql_result($result, 0);
if($browserswive == "Mozilla Firefox"){
echo '<img alt="FireFox" height="32" src="images/fox-icons.png" width="32">Hits '.$browser_count.' '.$browserswive.'<br>';
}
elseif($browserswive == "Internet Explorer"){
echo '<img alt="Internet Explore" height="32" src="images/ie-icons.png" width="31">Hits '.$browser_count.' '.$browserswive.'<br>';
}
elseif($browserswive == "Google Chrome"){
echo '<img alt="Google Chrome" height="32" src="images/chrome-icons.png" width="32">Hits '.$browser_count.' '.$browserswive.'<br>';
}
elseif($browserswive == "Apple Safari"){
echo '<img alt="Apple Safari" height="32" src="images/safari-icons.png" width="32">Hits '.$browser_count.' '.$browserswive.'<br>';
}
elseif($browserswive == "Opera"){
echo '<img alt="Opera " height="33" src="images/opera-icons.png" width="33">Hits '.$browser_count.' '.$browserswive.'<br>';
}
}
什麼你怎麼想看看它命令?輸出示例是多列還是單個字符串? – Sparky
我希望這些匹配按降序運行。上面的示例輸出是現在的顯示方式。 – MHowey