开发者

Retrieving a column from mySQL database and passing to array

I have previously constructed an array manually, e.g.:

<?php
$noupload = array('nick', 'cliff');
?>

but now I am trying to populate the array automatically from users in a MySQL database. So far I have this:

<?php
// Make a MySQL Connection
$debug=false;
$conn = mysql_connect("host","user","password"); // your MySQL connection data
$db = mysql_select_db("database");

$query = "SELECT * FROM users WHERE access LIKE '%listen%'"; 

$result = mysql_query($query) or die(mysql_error());

while($row = mysql_fetch_array($result)){
    $listen = "'". $row['login']. "', ";
}
?>

$listen constructs the user list in the way that I previously entered it manually (I tested this using echo), but I am not sure how to pass this to $noupload. 开发者_如何学Go I tried:

$noupload = array($listen);

but this didn't work. I think I'm close and would be grateful for some help over the final hurdle,

Thanks,

Nick


You can declare $listen as an array

$listen = array();
while ($row = mysql_fetch_array($result)) {
    $listen[] = "'". $row['login']. "'";
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜