In the mysql database I have the following table:
Notethatthecolumnfieldisinjsonformat.Ihavemultiplerecordsinasinglefield.Ineedascripttocounteachrecordseparatedbycommasandaddandassigntoavariable.Inthiscasethevariablewouldbesetto6.
InthecodebelowIgetthenumberofrecordsperline,butI'mnotabletodothesum.
$conexao=mysqli_connect('localhost','root','');$banco=mysqli_select_db($conexao,'movement');mysqli_set_charset($conexao,'utf8');$res=mysqli_query($conexao,"SELECT coluna FROM tabela");
while($r = mysqli_fetch_assoc($res)) {
echo count(json_decode($r['coluna'], true));
}