Tengo este código:
Código PHP:
$sql = "SELECT COUNT(ipusuario) as total FROM estadisticas";
$result = mysql_query($sql) or die(_DBERR. ' ' .mysql_error());
$t = mysql_fetch_row($result);
$qtotal = $t[0];
echo "<table width='100' border='0' cellspacing='0' cellpadding='0'>"
."<tr><td colspan='2'><img src='images/top/modstaticstop.gif'></td></tr>"
."<tr><td colspan='2' class='alterno fontbig normal bold lefline rigline topline botline'>Sistemas Operativos</td></tr>";
$query = "SELECT COUNT(ipusuario) AS total,sistemaoperativo FROM estadisticas GROUP BY sistemaoperativo";
$result = mysql_query($query) or die (_DBERR.mysql_error());
$soicon = array("windows.gif","macos.gif","linux.gif","freebsd.gif","sunos.gif","irix.gif","beos.gif","os2.gif","aix.gif");
$sotitle = array("Windows","MacOS","Linux","FreeBSD","Sun OS","Irix","BeOS","OS2","AIX");
while ($row = mysql_fetch_assoc($result)){
$sistemaoperativo[$row['sistemaoperativo']] = (100*$row['total'])/$qtotal;
echo "<tr><td width='27%' class='img fontbig lefline'><img src='images/ico/".$soicon[$row['sistemaoperativo']-1]."' border='0' align='absmiddle' class='cursor'> ".$sotitle[$row['sistemaoperativo']-1]."</td><td width='70%' class='img fontbig rigline'>";
MakeImagePor($sistemaoperativo[$row['sistemaoperativo']]);
echo " ".(round($sistemaoperativo[$row['sistemaoperativo']],2))." % [".$row['total']." usuarios]</td></tr>";
}
echo "<tr><td colspan='2' class='alterno fontbig normal bold lefline rigline topline botline'>Navegadores</td></tr>";
$sql = "SELECT COUNT(ipusuario) AS total, navegador FROM estadisticas GROUP BY navegador";
$result = mysql_query($sql) or die (_DBERR.mysql_error());
$bwtitle = array("Opera","Internet Explorer","Lynx","WebTV","Konqueror","Mozilla","Netscape","Otros");
$bwicon = array("opera.gif","iexplorer.gif","","","","","","",);
while ($row = mysql_fetch_assoc($result)){
$navegador[$row['navegador']] = (100*$row['total'])/$qtotal;
echo "<tr><td width='27%' class='img fontbig lefline'><img src='images/ico/".$bwicon[$row['navegador']-1]."' border='0' align='absmiddle' class='cursor'> ".$bwtitle[$row['navegador']-1]."</td><td width='70%' class='img fontbig rigline'>";
MakeImagePor($navegador[$row['navegador']]);
echo " ".(round($navegador[$row['navegador']],2))." % [".$row['total']." usuarios]</td></tr>";
}
echo "<tr><td class='botline rigline lefline' colspan='2'> </td></tr></table>";