Kevin
Kevin

Reputation: 23634

Not returning the entire values from the table

$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']));       
}

I get only the first set of values from the fields. I need all the values.

Upvotes: 1

Views: 91

Answers (1)

Greg
Greg

Reputation: 321736

You can only return once from a function. Build an array of results and return that:

$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;

Upvotes: 5

Related Questions