我的数据库 表//名称:帐户
id | login | password | macaddress
1 | ab | ex | 2X:D0:5X:5E:77:CX
2 | ac | example | 2X:D0:5X:5E:77:CX
3 | ad | example | 5X:Y0:GX:FE:27:G8
查询
$sql = pg_query("SELECT * FROM accounts where macaddress = '2X:D0:5X:5E:77:CX' ")
while( $row = pg_fetch_assoc($sql) )
echo "$row[id]";
结果:12
我想要的结果是:1,2
我希望你能帮助我解决这个问题。 谢谢
答案 0 :(得分:1)
首先将值放入数组中并加入它们。
$array = [];
$sql = pg_query("SELECT * FROM accounts where macaddress = '2X:D0:5X:5E:77:CX' ")
while( $row = pg_fetch_assoc($sql) )
$array[] = $row[id];
echo join(',', $array);