/    Sign up×
Community /Pin to ProfileBookmark

Do While Loop not working as expected

Hi all,
So I have two tables: 1) Landlords 2) Properties
Landlords stores all the landlords and the properties stores all the landlords properties and has a primary/foreign key respectively of landlord_id to link them.

There are two queries one to just load all landlords and one to load the properties based on the landlord_id found in query 1 (load landlords)

I have nested loops one for all the landlords, and the other for all the properies each landlord can have.
The landlords loop, brings in all the landlords perfectly well.
But the properties loop only loads the properties for the first record only.

I am using php and mysql. Not sure what is going on.
Any help would be appricated.

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@NachfolgerMay 17.2020 — @catalepticstate#1618520

POST THE CODE. Why would you ask a question and not even post the code? That's insane.

If you want my theory, I bet when you're appending to the array, you're doing it incorrectly.

Eg.
``<i>
</i>for (x in y) {
$landlord["Properties"] = xyz
}<i>
</i>
`</CODE>
Instead of
<CODE>
`<i>
</i>for (x in y) {
$landlord["Properties"][] = xyz
}<i>
</i>
`</CODE>

Take note of the difference between <C>
$landlord["Properties"]</C> and <C>$landlord["Properties"][]`.
Copy linkTweet thisAlerts:
@VITSUSAMay 20.2020 — @catalepticstate#1618520 Can you please share the screenshot of the code? It will more helpful to understand the exact problem.
Copy linkTweet thisAlerts:
@NogDogMay 20.2020 — > @VITSUSA#1618619 Can you please share the screenshot of the code? It will more helpful to understand the exact problem.

Preferably the actual (and hopefully on the relevant parts) code within this forum's ... tags. It's really difficult to copy/paste text from a screenshot if you want to play around with it. ;)
×

Success!

Help @catalepticstate spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.27,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...