开发者

HOw do i get all the data in a fieldname (Name) in database and store it in a variable array? in PHP and MYSQL

$name开发者_JAVA百科 = mysql_num_rows($result);
$i = 0;
while($i < $name){  
    $nameAll = mysql_result($result, $i);           
    $i++;   
}


you can use code from the first example here.

$sql = "SELECT id as userid, fullname, userstatus 
        FROM   sometable
        WHERE  userstatus = 1";

    $result = mysql_query($sql);

    // While a row of data exists, put that row in $row as an associative array
    // Note: If you're expecting just one row, no need to use a loop
    // Note: If you put extract($row); inside the following loop, you'll
    //       then create $userid, $fullname, and $userstatus
    $values = array(); 
    while ($row = mysql_fetch_assoc($result)) {

        $values[] = $row["fullname"];

    }
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜