Skip to content
Advertisement

Tag: foreach

laravel foreach loop in controller

i have a problem about looping data in controller (laravel 4). my code is like this: when i want to use foreach to loop for $product result with code like this: the result is returning error Undefined property: IlluminateDatabaseEloquentCollection::$sku so, i try to improvise a little with this code: the code returning error like this: Invalid argument supplied for foreach()

foreach slider only shows one db entry

I’ve got an array which gets all the testimonials from the database table and displays them via a foreach array. I want some kind of a slider which fades-in and fades-out the results. This is my query: My PHP foreach code: My piece of Javascript code It’s currently only showing ONE (the latest in the database) and only fades-in and

Using isset() inside a foreach doesn’t work?

Basically, I have an indefinite number of buttons that I want to generate from variables held in the mysql database. Now when I try to press the buttons nothing happens. This is the code I thought might work for that: There are no errors. I think it’s because I can’t use isset inside a foreach this way. Is there some

Invalid argument supplied for foreach()

It often happens to me to handle data that can be either an array or a null variable and to feed some foreach with these data. When you feed a foreach with data that are not an array, you get a warning: Warning: Invalid argument supplied for foreach() in […] Assuming it’s not possible to refactor the get_values() function to

Advertisement