olaoyesunday 0 Posted August 20, 2020 Report Share Posted August 20, 2020 Please, I want to convert this single select option to multiple choice select options. i,e to select more than one option in the select dropdown <?php $get_sizes = "select * from sizes"; $run_sizes = mysqli_query($con,$get_sizes); while ($row_sizes=mysqli_fetch_array($run_sizes)){ $size_id = $row_sizes['size_id']; $size_name = $row_sizes['size']; echo " <option value='$size_id'> $size_name </option> "; } ?> </select><!-- form-control Finish --> Quote Link to post Share on other sites
Larry 428 Posted August 21, 2020 Report Share Posted August 21, 2020 Add the "multiple" property to the opening select tag: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/select Quote Link to post Share on other sites
olaoyesunday 0 Posted August 21, 2020 Author Report Share Posted August 21, 2020 Thanks very much sir, I still need your help. How do I allow size_id column in product table to store more than one size_id on a single record? I tried it directly in phpmyadmin to insert more than one size_id on the size_id column but it was given error Quote Link to post Share on other sites
Larry 428 Posted August 22, 2020 Report Share Posted August 22, 2020 Ah, no, you can't do that. You'll need to use PHP to break the multiple selections into their single counterparts and insert each one separately. 1 Quote Link to post Share on other sites
olaoyesunday 0 Posted August 23, 2020 Author Report Share Posted August 23, 2020 okay thanks but I am trying to use foreach loop where I want to enter the $_Post['size'] into database but don't know how to assign the $i variable below back to the $size variable if(isset($_POST[‘submit’])){ $size = $_POST[‘size’]; foreach ($size as $i) { echo ("$i<br>"); } $insert_product = "insert into products (size) values (’$size’) Quote Link to post Share on other sites
Larry 428 Posted August 24, 2020 Report Share Posted August 24, 2020 You need to execute the query from within the FOREACH as that's the only place you have access to each individual selected size. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.