funnymoney
05-12-2008, 02:40 PM
I need to find way to extract an array of users from database, but extract() function doesn't work like i thought it will
I'm using simple way to loop through database, but can't find simple way to return that array so i can use it later.
Code:
public function statistike() {
$sql = ("SELECT * FROM korisnici");
$result = mysql_query($sql);
while ($podaci = mysql_fetch_assoc($result)) {
echo $podaci["id"]. " ";
echo $podaci["ime"]. " ";
echo $podaci["email"]."<br>";
extract($podaci);
}
mysql_free_result($result);
print_r($ime);
return $podaci;
}
i read PHP manual, and function extract should give me arrays $ime ($name) $id and $email, but it doesnt work.
for now i'm using array_push, but i thought it would be possible to get array of names by using extract, but looks like it doesn't work
I'm using simple way to loop through database, but can't find simple way to return that array so i can use it later.
Code:
public function statistike() {
$sql = ("SELECT * FROM korisnici");
$result = mysql_query($sql);
while ($podaci = mysql_fetch_assoc($result)) {
echo $podaci["id"]. " ";
echo $podaci["ime"]. " ";
echo $podaci["email"]."<br>";
extract($podaci);
}
mysql_free_result($result);
print_r($ime);
return $podaci;
}
i read PHP manual, and function extract should give me arrays $ime ($name) $id and $email, but it doesnt work.
for now i'm using array_push, but i thought it would be possible to get array of names by using extract, but looks like it doesn't work