sql - PHP: output count() -
how work count()
$sql = $connect->prepare("select count() discos_events e inner join discos_events_guests eg on (e.id = eg.eid) inner join users u on (eg.uid = u.id) e.did =:id"); $sql->bindvalue(":id", $cid); $sql->execute();
...then what? echo $sql["count"];
? output count?
you need alias name count()
column:
$sql = $connect->prepare("select count() num_events discos_events e inner join discos_events_guests eg on (e.id = eg.eid) inner join users u on (eg.uid = u.id) e.did =:id"); $sql->bindvalue(":id", $cid); // fetch results , access alias $sql->execute(); $result = $sql->fetch(); echo $result['num_events'];
Comments
Post a Comment