0

I'm trying to retrieve data using while and it won't work. The page just keeps loading and ends up with a blank page; no errors or anything but, when i use foreach, it works.

Any explanation?

The code i'm using doesn't work

 while($row=$this->functionname){
    echo $row['fieldname'];
  }

when i use this one below, it works.

foreach($this->functionname as $row) {
   echo $row['fieldname']
}

I have tried placing in diferent files but i have the same result.

3
  • Please include some code to demonstrate the problem. Mar 25 '20 at 22:57
  • The while statement doesn't iterate through $this->functionname. It's like saying while($i=1) {...}. It's always true and you get an infinite loop. Mar 26 '20 at 21:20
  • Oh sure. Thank you Robbie. Mar 27 '20 at 11:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.