Hack Forums
[PHP] pdo inside a html drop down - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Web Development (https://hackforums.net/forumdisplay.php?fid=183)
+---- Thread: [PHP] pdo inside a html drop down (/showthread.php?tid=6230284)



pdo inside a html drop down - Geatzo - Dec 28, 2022

PHP Code

<?php
                                                
                                                
$query9 
= $db->prepare('SELECT * FROM categories WHERE takeawayid= ? ');
 
$query9->execute(array($_SESSION['id']));
    
// alternatively you could use PDOStatement::fetchAll() and get rid of the loop
    // this is dependent upon the design of your app
    
foreach ($query9 as $row9) {
                                                
                                                
?>
 <select name="country" class="form-control form-select form-select-lg select2" data-bs-placeholder="Select Country">
 <option value="<?php echo $row9['cat_id']; ?>"name = "topic_cat"id="topic_cat" ><?php echo $row9['cat_name']; ?></option>
    </select>                                        
<?php } ?>
                                              
                                      
                                    </div>
                                              
                                              
                                        <input type="submit"   class="btn btn-success my-1">
                                              
                                      </form> 


Im off course opening the form higher up and its outputting all the results into the drop down but when i submit the post the form is empty ?








Found the issue i called the select country higher up all fixed now