/    Sign up×
Community /Pin to ProfileBookmark

Change foreach into something like where?

I’m just learning PHP now so I don’t know of all the possibilities and stuff. If I have this in the code:

[code=php]
<?php foreach ($languages as $language) { ?>

Bunch of fields here

<?php } ?>
[/code]

That returns a bunch of fields for every language there is. In this case, there’s two languages, 1 and 2. How do I change that foreach statement so it only returns where $languages = “2”? I tried messing with WHERE but had no luck. I don’t even know if WHERE could be used the way I tried to. lol

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@themartyJan 21.2011 — you'll have to be more specific. Where and how is $languages created and what does it look like? Also what do you mean with 'where $languages=2' ? You're treating it as an array in your code, but compare it to an integer - that doesn't make sense. What is it you really want to filter?
×

Success!

Help @agalloch 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 5.18,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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