这是我遇到的问题。
我的表格具有MSISDN列,我想分别计算每个数字并计算每个数字出现多少次
然后将其显示在表格中的特定编号和发生的时间,例如
Number(MSISDN) | No of times
Here is my code, i am stocked as i dont know what step to take or how to move from where i am.
$go=mysql_query("SELECT * FROM request_from");
$go2=mysql_fetch_array($go);
$i=0;
while($go2=mysql_fetch_array($go))
{
$i++;
$tel=$go2['msisdn'];
//counting number of time each number occurs
$xtt=mysql_query("SELECT * FROM request_from WHERE msisdn='$tel'");
$xtt2=mysql_fetch_array($xtt);
$g=1;
while($xtt2=mysql_fetch_array($xtt))
{
$g++;
}
echo $tel occurs $g times; //for all the phone numbers, it displays the number of time each number occurs
最佳答案
做这个:
SELECT msisdn ,sum(1) anz FROM request_from
GROUP BY msisdn;
关于php - 分别计算和获取每个数字,并计算每个数字出现在数据库中的次数,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/32260153/