Answer the question
In order to leave comments, you need to log in
How to count and display the number of records in a database cell in PHP?
There is such a query in the database. If I understand correctly, this is the main request to the _users database
$row = $db->super_query( "SELECT * FROM " . USERPREFIX . "_users WHERE user_id = '{$id}'" );
Answer the question
In order to leave comments, you need to log in
When querying the database, the $row variable will contain an array with user data. The array will contain the $row['pay_news'] element, which in turn will contain the string value "news id separated by commas".
You need to
1) Split the string into an array using a comma separator
2) Count the number of elements in the resulting array
$idNewsArray = explode(',' , $row['pay_news']);
$countNews = count($idNewsArray );
echo $countNews;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question