如何获取数据库中字段名(名称)中的所有数据并将其存储在变量数组中?在PHP和MYSQL中

|
$name = mysql_num_rows($result);
$i = 0;
while($i < $name){  
    $nameAll = mysql_result($result, $i);           
    $i++;   
}
    
已邀请:
您可以在此处使用第一个示例中的代码。
$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\"];

    }
    

要回复问题请先登录注册