Ver Mensaje Individual
  #1 (permalink)  
Antiguo 16/12/2004, 14:43
Avatar de Reynier
Reynier
 
Fecha de Ingreso: noviembre-2002
Ubicación: Por ahí en algún sitio
Mensajes: 1.844
Antigüedad: 21 años, 5 meses
Puntos: 1
Consulta + PHP + Como

Hola:
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'>&nbsp;</td></tr></table>"
El mismo me resuelve en parte mi problema pues me muestra el porciento, pero si el sistema operativo no esta referenciado en la BDatos con ningun dato entonces no me muestra detalles del mismo. O sea, si mi dato es uno me muestra 100% pero ahora si el dato 2 no esta en BD entonces no muestra nada cuando lo que quiero hacer es que me muestre 0%. Que hago ??
__________________
Ing. Reynier Pérez Mira