Jump to content

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


Synergic

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]
Link to comment
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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.