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.
#(Solved) -Returning Data from loop
11 messages · Page 1 of 1 (latest)
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.
You mean the condition sir ?
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
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
Sir do you mean is after i declare another variable after the if-condition ?
You’ve asked twice about if condition. No.
I think you need to do a basic PHP tutorial on loops.
Okay sir noted on that . thank you
Im done seems i forgot some basics . thank you sir @wicked condor and sir @digital hedge