#(Solved) -Returning Data from loop

11 messages · Page 1 of 1 (latest)

gritty nebula
#

Hello. I have a problem returning data from loop . I have a table called item and item attributes . First I get Data from the item then i loop it to check if it has an item attributes , but when i try to merge and return it . it doesnt merge . Is there a right way to merge and return this data ? . Sorry for my bad english.

wicked condor
#

You’re just overwriting the same variable in each iteration of your loop.

#

You also have an N+1 problem there since you’re doing a query inside each iteration.

gritty nebula
#

Its just a condition sir if the lot has an item . there is a time where a lot doesnt have any item in it . i thought it would be a good precaution

digital hedge
#

No that has nothing to do with the if-condition. Like Martin said, you're overwriting a variable in each iteration of the loop, so at the end of the loop you end up with a variable that only has 1 object

gritty nebula
#

Sir do you mean is after i declare another variable after the if-condition ?

wicked condor
#

I think you need to do a basic PHP tutorial on loops.

gritty nebula
#

Okay sir noted on that . thank you

gritty nebula
#

Im done seems i forgot some basics . thank you sir @wicked condor and sir @digital hedge