Jerru Jerru - 1 month ago 20
SQL Question

How to count non-null values in table php

How do i count non-null variables in php database?(SQL)

this is my existing code and database in the picture

$jack5 = mysql_fetch_array(mysql_query("SELECT * FROM z3 WHERE ID='$users_Names' AND Score IS NOT NULL "));
echo $jack5;


when i echo the result, i get Notice: Array to string conversion etc... error

Im new to this so any help is appreciated!
z3 is my table name
Score is my column name

Answer

Try this:

$result = mysql_query("SELECT * FROM z3 WHERE ID='$users_Names' AND Score IS NOT NULL "));
$rowCount = mysql_num_rows($result);  // It will return the number of rows in result set