/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] drop down select without the drop down, help

in the topic drop down select, you gave me

[code=php]
$accessLevels = array(1 => ‘Administrator’, 2 => ‘Member’);
echo “<select name=’edit_accesslvl’ size=’1′>n”;
foreach($accessLevels as $key => $value)
{
$selected = ($key == $queryrow[‘accesslvl’]) ? ” selected=’selected'” : ”;
echo “<option value=’$key’$selected>$value</option>n”;
}
echo “</select><p>”;
[/code]

which of course does create a drop down with the correct access level selected, but Now I want that same thing, but out of a drop down, I simply want it to echo the correct one, not each one, But I am unsure how to do this. So I come to you.

to post a comment
PHP

6 Comments(s)

Copy linkTweet thisAlerts:
@bokehJul 15.2006 — [code=php]echo $accessLevels[$queryrow['accesslvl']];[/code]
Copy linkTweet thisAlerts:
@Heavy_MetalauthorJul 15.2006 — well, i am using numbers for my access levels though, and I would really like to keep it that way. But then I can simply use if statements cant I *slaps self across face* why do I even bother?
Copy linkTweet thisAlerts:
@bokehJul 15.2006 — I know what you are using and I advised against it at the time but if you use the line I just posted it will echo the word not the numeric value.
Copy linkTweet thisAlerts:
@Heavy_MetalauthorJul 15.2006 — how do you know what i am using, and also, how will it tell that one is the admin and two is the member?
Copy linkTweet thisAlerts:
@bokehJul 15.2006 — Because it reads these values from $accessLevels. Have you tried running it?
Copy linkTweet thisAlerts:
@Heavy_MetalauthorJul 15.2006 — It seems I twice have misread code today, I thought you ran this [code=php]
$accessLevels = $queryrow['accesslvl']; [/code]
, I honestly am just not in the zone today, Sorry.
×

Success!

Help @Heavy_Metal 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.28,
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,
)...