Reputation: 37
I want to use multiple queries to count multiple values and display those values in a table.
$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'];
The echo above gives me no result. What am i doing wrong?
Upvotes: 0
Views: 69
Reputation: 16086
Try like this-
$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'];
Note: mysql_* functions are deprecated, using them not recommended.
Upvotes: 1