/    Sign up×
Community /Pin to ProfileBookmark

Dynamic menu in email

I’m posting the results of a form with several drop menus that are populated from a database. The form posts ok but I am getting the number (_id) of the form item rather than the text label.

It is also being inserted into a database, so I wonder where I’m going wrong?

Thanks in advance.

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@h3r0Nov 25.2007 — <option value="'.$id.'">$name</option>

Is that what you have now? If you want the Name instead of the id, replace your option value with the name instead of the id.
Copy linkTweet thisAlerts:
@Kyleva2204Nov 25.2007 — If your inserting data into a database the corresponds with the form data, its best to use an ID, that way you don't have things repeating in your database.. However, if you want to use both the ID and Name in the value, then set the value of the item to something like "1--Item1" and then on the resulting page have

$array = explode('--',$_POST['my_item']);

list($id,$item_name) = $array;

That will then populate $id, and $item_name with the.. id and item name.

hope this helps.
Copy linkTweet thisAlerts:
@SiriunsonauthorNov 26.2007 — Thank you both for your help. Using the advice offered, here, for others is my original code:

[CODE]<select name="saladname" class="dropMenus" id="saladname">
<option value="0">select</option>
<?php
do {

?>
<option value="<?php echo $row_rsSalad['salad_id']?>"><?php echo $row_rsSalad['saladname']?></option>
<?php
} while ($row_rsSalad = mysql_fetch_assoc($rsSalad));
$rows = mysql_num_rows($rsSalad);
if($rows > 0) {
mysql_data_seek($rsSalad, 0);
$row_rsSalad = mysql_fetch_assoc($rsSalad);
}
?>
</select>[/CODE]

And here is the modified line:
[CODE] <option value="<?php echo $row_rsSalad['saladname']?>"><?php echo $row_rsSalad['saladname']?></option>[/CODE]
×

Success!

Help @Siriunson 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 6.17,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

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