我需要帮助设置MySQL结果的用户变量。
SELECT ptype, COUNT(ptype) FROM `TABLE 2` GROUP BY ptype ORDER BY COUNT(ptype)
我想为所有类型的结果值创建一个用户变量(TD = 5 ,DT = 13 ,...等)
我该怎么做?
DW
<?$connector=mysqli_connect("localhost","", "","");
$res2=mysqli_query($connector, "SELECT ptype, COUNT(ptype) FROM `TABLE 2` GROUP BY ptype");
for (i = 0; i <12; i++) {
$carrier[i] = while ($row=mysqli_fetch_array($res3)) {echo $row['COUNT(carrier)'];}
}
&#13;
答案 0 :(得分:0)
尝试:
$ptype = array();
if($res2=mysqli_query($connector, "SELECT ptype, COUNT(ptype) AS pnum FROM TABLE 2 GROUP BY ptype")){
while($row=mysqli_fetch_array($res2)) {
$ptype[] = $row['pnum'];
}
} else {
printf("Error: %s\n", mysqli_error($connector));
}