Mammouth du PHP |
643 Messages
12 mai 2016, 07:10
Alors j'ai suivi tes conseils et j'en suis donc à:
if (empty($_REQUEST['ville'])) {
$liste = $bdd->query("SELECT id_type_loisirs,COUNT(*) as nb FROM loisirs WHERE id_region = ".$region_id." AND `loisirs`.`date_fin_sortie` > NOW() AND `loisirs`.`valide` = 1 GROUP BY id_type_loisirs " );
$liste .= " GROUP BY id_type_loisirs HAVING nb >= 1 ORDER BY nb DESC LIMIT 0,30";
while($row = $liste->fetch(PDO::FETCH_ASSOC)) {
$count[$row['id_type_loisirs']] = $row['nb'];
}
asort($aLoisirs);
foreach($aLoisirs as $k => $v) {;
$nb = array_key_exists($k, $count) ? $count[$k] : 0;
// Si il y a un loisir de renseignée et aucune page demandée
if (!empty($_REQUEST['loisir']) && empty($_GET['page']) && empty($_REQUEST['region']) && empty($_REQUEST['departement'])) {
echo '<li><a href="activite-'.simplification(strtolower($v)).'.html">'.$v.'</a><span class="subDropdown plus">'.$nb.'</span></li>'."\n";
}
Mais une erreur se produit:
Catchable fatal error: Object of class PDOStatement could not be converted to string in C:\wamp\www\digital\list.php on line 978
cette ligne correspond à :
$liste .= " GROUP BY id_type_loisirs HAVING nb >= 1 ORDER BY nb DESC LIMIT 0,30";
Quel est le problème ?
Merci encore