我已经用来自mysql的数据填充了我的android微调器。但我得到的不是每种类型一个数据。示例我的数据库中有2个篮球,android微调器显示的是2个篮球,而不是1个
菲律宾比索
$sql = "select s_name from sport order by s_name asc;";
$con = mysqli_connect($server_name,$mysql_user,$mysql_pass,$db_name);
$result = mysqli_query($con,$sql);
while($row=mysqli_fetch_array($result))
{
$tmp[] = $row;
}
echo json_encode ($tmp);
mysqli_close($con);
?>
这是我得到的答复。而不是只得到一个值。我在我的android微调器中从s戋u name获得所有信息
[{"0":"Basketball","s_name":"Basketball"}, {"0":"Basketball","s_name":"Basketball"},
{"0":"Basketball","s_name":"Basketball"},
最佳答案
您可以在查询中使用group by
:
$sql = "select s_name from sport GROUP BY s_name order by s_name asc;";