I'm trying to count the rows with the same id
|curs_code|cursistnr|Mark|Payed| C# 20 6 50 PHP 25 8 100 C# 8 7 100 the output needs to be
C#, 2times
I've tried
$sql = "SELECT count(curs_code) as 'count_of_curs' FROM cursus where curs_code='$id'"; $query = $magazijn->query($sql); return $query->fetchAll()); but gives me this output:
C# array (size=1) 0 => array (size=2) 'count_of_curs' => string '1' (length=1) 0 => string '1' (length=1) PHP array (size=1) 0 => array (size=2) 'count_of_curs' => string '1' (length=1) 0 => string '1' (length=1) your thought about this?
C#appear to be the same to you, but they are actually different values, likely due to "hidden" whitespace characters in one of the values. As a test, try a query likeSELECT curs_code, HEX(curs_code), CHAR_LENGTH(curs_code) FROM cursus WHERE curs_code LIKE '%C#%'.