计算多个值查询

时间:2013-12-10 13:50:18

标签: php mysql

我想使用多个查询来计算多个值,并在表格中显示这些值。

$resultnieuws = mysql_query("select gamer_int, count(gamer_int) as gamer_count_nieuws     FROM berichten WHERE gamer_int LIKE 'Kenny' AND soort LIKE 'nieuws'");
$resultvideo = mysql_query("select gamer_int, count(gamer_int) as gamer_count_video FROM berichten WHERE gamer_int LIKE 'Kenny' AND soort LIKE 'video'");

echo $resultnieuws['gamer_count_nieuws'];
echo $resultvideo['gamer_count_video'];

上面的回声没有给我任何结果。我做错了什么?

1 个答案:

答案 0 :(得分:1)

试试这个 -

    $resultnieuws = mysql_query("select gamer_int, count(gamer_int) as gamer_count_nieuws     FROM berichten WHERE gamer_int LIKE 'Kenny' AND soort LIKE 'nieuws'");
    $resultvideo = mysql_query("select gamer_int, count(gamer_int) as gamer_count_video FROM berichten WHERE gamer_int LIKE 'Kenny' AND soort LIKE 'video'");

    $row1 = mysql_fetch_array($resultnieuws);
    $row2 = mysql_fetch_array($resultvideo);

    echo $row1['gamer_count_nieuws'];
    echo $row2['gamer_count_video'];

注意:不推荐使用mysql_ *函数,不建议使用它们。