Select some non-working

I have a dropdown menu in html but it won't select multiple values. here is the code I have for this:

<div class="col-sm-10">          
    <select multiple id="cmbService" name="cmbService" class="form-control" >
        <option value="0">- Select One -</option>
            <?php                                       
                try{
                    $dbHost = "localhost";
                    $dbUser = "mdchadmin";
                    $dbPass = "123456";
                    $dbName = "mdch_new";

                    $conn = new mysqli($dbHost, $dbUser, $dbPass, $dbName);
                    if ($conn->connect_error) {
                        die("Connection failed: " . $conn->connect_error);
                    } 
                    $sql = "SELECT PROMO_NUMBER, PROMO_NAME FROM PROMOS where status=1";
                    $result = $conn->query($sql);
                    if ($result->num_rows > 0) {
                        while($row = $result->fetch_assoc()) {
                            echo "<option value=\"{$row['PROMO_NUMBER']}\">{$row['PROMO_NAME']}</option>";
                        }
                    }                                       
                    $conn->close(); 
                }catch (Exception $e) {
                    echo 'Error: ' . $e->getMessage();
                }                                           
            ?>
    </select>
</div>

      

EDITOR: IT NOW WORKS THANKS FROM ANSWER. BUT NOW I have a NEW PROBLEM (kinda) and I'm going through it

so i did what suggested and im getting this $ customer array in another php file which results in:

te,GIAN MARCO.'_'.1235
g,g.'_'.123

where 1235 and 123 are  the  data on the mobile numbers column.
the problem is , when i do 

$mobile=(explode("_",$customers));
it doesn't give me anything when i output it via: 

foreach($mobile as $z) {
echo $z; echo "<br>";}

      

@identity unknown

+3


source to share


1 answer


You just need to add a square bracket to your attribute name

name="cmbService[]"



 <select id="cmbService" name="cmbService[]" class="form-control multiple " >

      

+5


source







All Articles