/    Sign up×
Community /Pin to ProfileBookmark

Select Box Question

I’m trying to build a select box for my webpage that I’m making, but when I select an option and hit submit, it only passes the first word of the string. here is my code:

<form action = “http://cs.gettysburg.edu/~laytjo01/cs360/addowner.php” method = “post”>
<table>
<tr>
<td><b>Add to DB</b></td>
<td><SELECT name = “anime”>
<?php
$x=0;
while ($x<$count){
$opt = “<OPTION value = $list[$x]>$list[$x]</OPTION>”;
$x++;
echo $opt;
}
?>
</SELECT>
</tr>
</table>

<input type = “submit” value = “Add to Contact List” />

</form>

The $list has the names of animes so they are 3 and 4 words long sometime, but if i have say “Great Teacher Onizuka” as an option it only passes great. if anyone could tell me what to change, that would be great. Thanks!

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@NogDogApr 23.2005 — You need to quote the value. Also, you can clean up the code a bit by using a for loop:
[code=php]
<?php
for($x=0; $x<$count; $x++) {
echo "<OPTION value='{$list[$x]}'>{$list[$x]}</OPTION>n";
}
?>
[/code]
×

Success!

Help @hgslasd56 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.19,
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,
)...