Ver Mensaje Individual
  #4 (permalink)  
Antiguo 12/04/2009, 04:09
Avatar de b0zZy
b0zZy
 
Fecha de Ingreso: enero-2009
Ubicación: Francia
Mensajes: 28
Antigüedad: 15 años, 3 meses
Puntos: 0
Respuesta: Total de produtos en cada categoria !

Cita:
Iniciado por pacmanaman Ver Mensaje
while($fila = mysql_fecth_array($results))
{
echo $fila['cat_id']."-". $fila['Total'];
}

SaluDOS!
Hola pacmanaman, gracias por contestar.
Lo he intentado asi:
Código PHP:
$sql="SELECT c.cat_id, COUNT( cp.cat_id ) AS total
FROM tbl_product AS c
LEFT JOIN tbl_category AS cp ON cp.cat_id = c.cat_id
GROUP BY c.cat_id"
;
while(
$fila mysql_fecth_array($results))
{
echo 
$fila['cat_id']."-"$fila['Total'];

pero me da -> Fatal error: Call to undefined function mysql_fecth_array() in C:\wamp\www\include\categoryList.php on line 27
Aqui dejo todo el categorylist, puede que el error venga de atras
Código PHP:
<?php
if (!defined('WEB_ROOT')) {
    exit;
}

$categoryList    getCategoryList();
$categoriesPerRow 6;
$numCategory     count($categoryList);
$columnWidth    = (int)(100 $categoriesPerRow);
?>
<table width="100%" border="0" cellspacing="0" cellpadding="20">
<?php 
if ($numCategory 0) {
    
$i 0;
    for (
$i$i $numCategory$i++) {
        if (
$i $categoriesPerRow == 0) {
            echo 
'<tr>';
        }
        
        
// Tenemos la $url, $image, $name, $price
        
extract ($categoryList[$i]);
        
    
$sql="SELECT c.cat_id, COUNT( cp.cat_id ) AS total
FROM tbl_product AS c
LEFT JOIN tbl_category AS cp ON cp.cat_id = c.cat_id
GROUP BY c.cat_id"
;
while(
$fila mysql_fecth_array($results))
{
echo 
$fila['cat_id']."-"$fila['Total'];
}


    echo 
"<td width=\"$columnWidth%\" align=\"center\"style=vertical-align:baseline><a href=\"$url\"><img src=\"$image\" border=\"0\"><br>$name<br></a>()</td>\r\n";    
    
        if (
$i $categoriesPerRow == $categoriesPerRow 1) {
            echo 
'</tr>';
        }
        
    }
    
    if (
$i $categoriesPerRow 0) {
        echo 
'<td colspan="' . ($categoriesPerRow - ($i $categoriesPerRow)) . '">&nbsp;</td>';
    }
} else {
?>
    <tr><td width="100%" align="center" valign="center">Aucune</td></tr>
<?php    
}    
?>
</table>