Jump to content


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


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:


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


Share this post

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

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

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)


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.