我想要这样的东西?
$sql = mysql_query("SELECT lid, ip FROM lua where uid='$uid'");
$rows = mysql_fetch_array($sql);
$ip = $rows['ip'];
$res = array('value 1 of $ip from datebase','value 2 of $ip from datebase','value 3 of $ip from datebase.......');
?>
有可能吗? 帮助相关... thnxx ..
答案 0 :(得分:1)
$arr = array();
while ($rows = mysql_fetch_array($sql)) {
array_push($arr,$rows['ip']); // and so on if you willing other values to be in your array
}
var_dump($arr); // test your array
注意:虽然不推荐使用mysql
,但请改用mysqli
或pdo
个扩展程序。请参阅有关此问题的this帖子
答案 1 :(得分:1)
试试这个:
$arrResult = array();
while ($row = mysql_fetch_array($sql)) {
$arrResult[] = $row['ip'];
}
答案 2 :(得分:0)
$result = mysql_query("SELECT ip FROM lua where uid='$uid'");
$ip = array();
while ($ip[] = mysql_fetch_field($result));
$ip = array_filter($ip);