pass html form select value to php $_POST - pls help!!!

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
phpfly
Forum Newbie
Posts: 1
Joined: Sun Feb 16, 2014 8:45 pm

pass html form select value to php $_POST - pls help!!!

Post by phpfly »

hi. ...I have an html form where i am trying to pass the value of a select option to $_POST for use in another php file...the field of interest in the form is pre-populated with a selected option. However, the form is passing the same selected value, regardless of whether i select a different option. pls show error of my ways

here is the form code:

<form action="edit_product.php" method="post"
id="edit_product_form">

<label>Category:</label>
<select name="category_id">
<?php foreach ($categories as $category) : ?>
<option value="<?php $category['categoryID']; ?>"
<?php if ($category['categoryID'] == $category_id) echo " selected" ?>>
<?php echo $category['categoryName']; ?>
</option>
<?php endforeach; ?>
</select>
</form>

no matter what i select from the drop-down, what is passing appears to be the initial value of the selected option (value="<?php $category['categoryID']; ?>")..what am i missing to allow me to pass the newly selected option? thanks!!!!!
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: pass html form select value to php $_POST - pls help!!!

Post by requinix »

Actually it will be passing the right value. I suspect the place where you try to get or use that is where the problem is.
Post Reply