Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 12/04/2022 in all areas

  1. Slightly different approach then. Store the category query results in an array. $stmt = $pdo->query("SELECT categoryID , categoryName FROM tbl_categories WHERE categoryActive = 1 ORDER BY categoryID "); $cat_options = []; /// store cat data in array foreach ($statement as $row) { $cat_options[$row['categoryID']] = $row['categoryName']; } // main loop here while ($row = $stmt->fetch()) { echo "<select name='categoryID' class='select200px' required> <option value=''>Select...</option>"; foreach ($cat_options as $id => $cat) { $sel = $row['categoryID'] == $id ? 'selected' : ''; echo "<option $sel value='$id'>$cat</option>"; } echo "</select>"; }
    1 point
This leaderboard is set to New York/GMT-04:00
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.