Jump to content

Archived

This topic is now archived and is closed to further replies.

Synergic

how do i store mysql_fetch_array($query) into a variable?

Recommended Posts

As part of making my code more elegant and following an mvc pattern i want to store a query result inside a variable where i can invoke it else where besides the presentation layer.

I've tried:

[code]

$result = mysql_fetch_array($quer);

while($result) {
}

ends up being an endless loop. Do i need to continue to update the variable as i scroll through the rows?

[/code]

Share this post


Link to post
Share on other sites
this is what you need

[code]while ($result = mysql_fetch_array($quer)) {
//code here
}[/code]

The way you were doing it ment that while $result exists do what ever is between the brackets
The way i have shown above means that while $result can be get the next value from mysql_fetch_array($quer)

regards
Liam

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.