使用Dropdown值更新MySql DB

My update statement isn't working correctly, I am attempting to pull the data from the database, populate a dropdown with either "Y" or "N" inside it, on submit the values are entered into the database and the page refreshes.

So far I have my list of items, each with correctly populated dropdown, it is now my submit that is failing to work.

<?php
    $updatedFeatProd = $_POST['featuredProduct'];
    var_dump($updatedFeatProd);

    if ($_POST) {
        foreach ($_POST['featuredProduct'] as $key => $val) {
            $query = 'UPDATE tblProducts SET featuredProduct = ' . $updatedFeatProd . '
                    WHERE fldID = ' . $val;
            $sql = dbQuery($query);
        }
    }
    $sql = dbQuery('SELECT fldId, fldName, featuredProduct FROM tblProducts');
?>

<form method="post" action="#" name="featuredProd">
    <table>
    <tr><td><p>Product Name</p></td><td><p>Is a featured product?</p></td></tr>

<?php
    $products = dbFetchAll($sql);
    foreach ($products as $product) { 
        //var_dump($product['fldName']);
?>
    <tr>
        <td>
            <p><?php echo $product['fldName']; ?></p>
        </td>
        <td>
            <select name="featuredDropdown">;
<?php
        if ($product['featuredProduct'] == 'Y') {
?>
                <option  value="<?php $product['fldId'] ?>"><?php echo $product['featuredProduct'] ?></option>
                <option value="<?php $product['fldId'] ?>">N</option>
<?php 
        } else {
?>
                <option value="<?php $product['fldId'] ?>"><?php echo $product['featuredProduct'] ?></option>
                <option value="<?php $product['fldId'] ?>">Y</option>
<?php 
        }
?>
            </select>
        </td>
    </tr>

<?php 
    }
?>

The presentaton here does not make much sence. You have a dropdown with the ProductName in one slot and a 'N' in another.

Once the user has selected 'N' for a product they have no idea what they have said NO to, as they can no longer see the product name that they have selected NO for.

It would make more sence to provide a <label> containing the product name and a YES/NO dropdown beside it for them to select from.

However the reason your update code is not working is that you have called the dropdown featuredDropdown

<Select name="featuredDropdown">

and you are trying to process a field called featuredProduct in the update code

foreach ($_POST['featuredProduct'] as $key => $val) {

Your next problem will probably be that you are oututting more than one <Select name="featuredDropdown"> so you need to make that into an array as well like this:

<Select name="featuredDropdown[]">

Then you will have an array of featuredDropdown in the $_POST array. $_POST['featuredDropdown'][]