计数id唯一的显示

时间:2014-04-23 09:55:00

标签: php mysql count

以下代码无效:

<?php 
        $sql = 'SELECT sum(display) AS nb_total FROM tracking where id_site ="'.$id_site.'"';
        $req = mysql_query($sql) or die('Erreur SQL !'.$sql.''.mysql_error());
        $data = mysql_fetch_array($req); 
        echo $data['nb_total']; 
?>
请帮助我

2 个答案:

答案 0 :(得分:1)

试试这个:

$sql = "SELECT sum(display) AS nb_total FROM tracking where id_site =$id_site";

答案 1 :(得分:0)

像这样纠正这条线

$sql = "SELECT sum(display) AS nb_total FROM tracking where id_site ='$id_site'";