Monday, 10 August 2015

populating an html dropdown with dynamic data from mysql database using php

code snippet:

<select name="item_name">
<option value="">Select an option</option>
include "db_config.php";
$sql="select * from tb_name";
<option value="<?php echo $result['column_id'];?>"><?php echo $result['column_name'];?></option>

if you dont want to reffer to the already db_config we created reffer to the post which uses the mysql function.

Replace the tb_name with the name of the database table your want to populate data from.
Replace the column_id with the correct column_id which you want to populate.
Replace the column_name with the database column name you want to be displayed.

No comments:

Post a Comment