Created
January 11, 2019 09:34
-
-
Save ErMandeep/19425946aeb1ff083b6ab346a4b99e81 to your computer and use it in GitHub Desktop.
fetch select option from database
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<select class="form-control" name="product_category_id" data-placeholder="Choose a Category" tabindex="1"> | |
<?php | |
$query = "SELECT * FROM category"; | |
$select_image = mysqli_query($connection, $query); | |
while($row = mysqli_fetch_assoc($select_image)){ | |
$id = $row['id']; | |
$cat_title = $row['cat_title']; | |
?> | |
<option value="<?php echo $cat_title; ?>" <?php if($product_category_id==$cat_title) echo 'selected="selected"'; ?>><?php echo $cat_title; ?></option> | |
<?php } ?> | |
</select> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment