Sunday, December 18, 2011

Binding data to dropdown list with php from mysql database

This is just a basic for some of you guys. But if you are new to it, it will take some times for you to figure it out. So, please follow the steps mentioned below, and you will get there in no time.

<select name="yourselection">
    <option value="">--Select--</option>
    <?php
$msql = mysql_query("SELECT * FROM manufacturer");
while($m_row = mysql_fetch_array($msql))        
        echo("<option value = '" . $m_row['m_code'] . "'>" . $m_row['m_name'] . "</option>");
  ?>
</select>

6 comments: