不返回表中的整个值

时间:2009-07-01 09:54:37

标签: php mysql

$result = mysql_query("SELECT * FROM project ORDER BY projectid");

while($row = mysql_fetch_array($result)) 
{
    return(array($row['projectid'],   $row['clientname'], 
                 $row['salesperson'], $row['prospect']));       
}

我只从字段中获取第一组值。我需要所有的价值观。

1 个答案:

答案 0 :(得分:5)

您只能从某个功能返回一次。 构建一系列结果并返回:

$result = mysql_query("SELECT * FROM project ORDER BY projectid");
$values = array();
while($row = mysql_fetch_array($result)) 
{
    $values[] = array($row['projectid'], $row['clientname'], $row['salesperson'], $row['prospect']);
}

return $values;