What i try to do is to get a mysql query to search in the table megabase in the column kla_abbonnement_groep for the words zilver,goud,platina and returns the amount of time the words are in the column into one number.
The database column consists out of 2x zilver, 2 x goud, 2 x platina.
I have the following code but it does not work. I have tried a lot of other methods but those where not displaying anything. The code below constantly displays a 1 but it should display a 6.
<?
include 'data/php/config.php';
// create query
$result = mysql_query("SELECT COUNT(*) FROM megabase WHERE kla_abbonnement_groep = 'zilver' AND kla_abbonnement_groep = 'goud' AND kla_abbonnement_groep = 'platina'");
$num_rows = mysql_num_rows($result);
echo "$num_rows";
?>
Thanks for any help in advance.
CHANGED THE CODE TO THE FOLLOWING WITH HELP FROM RIKESH
<?
include 'data/php/config.php';
// create query
$query = "SELECT COUNT(*) FROM megabase WHERE kla_abbonnement_groep = 'zilver' OR kla_abbonnement_groep = 'goud' OR kla_abbonnement_groep = 'platina'";
print mysql_result(mysql_query($query),0)
?>
The question that remains how can I use the number that is printed in for example a javascript on the same page.
When I add:
$result = mysql_result(mysql_query($query),0);
I get the error.
Parse error: syntax error, unexpected T_VARIABLE in ... on line 60
I GOT IT WORKING EVERYONE THANKS FOR THE HELP COULDNT HAVE DONE IT WITHOUT:
This is the working code!
<?
include 'data/php/config.php';
// create query
$query = "SELECT COUNT(*) FROM megabase WHERE kla_abbonnement_groep = 'zilver' OR kla_abbonnement_groep = 'goud' OR kla_abbonnement_groep = 'platina'";
print mysql_result(mysql_query($query),0);
$result1 = mysql_result(mysql_query($query),0);
?>