Jump to content


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

  • Please log in to reply
1 reply to this topic

#1 Synergic

  • Members
  • PipPip
  • Member
  • 21 posts

Posted 17 August 2006 - 08:12 AM

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?

#2 shocker-z

  • Members
  • PipPipPip
  • Advanced Member
  • 864 posts
  • LocationNottingham

Posted 17 August 2006 - 08:29 AM

this is what you need

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)

www: www.ukchat.ws | irc: irc.ukchat.ws chan: #blufudge

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users