Combo Box

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • AnkitaM
    New Member
    • Nov 2014
    • 1

    Combo Box

    I have one doubt. How to load data from the databse in to combobox..

    I have a mysql table machine

    one fields in the table filename

    I want to load the list of filename into the combobox..

    Thanks
  • Claus Mygind
    Contributor
    • Mar 2008
    • 571

    #2
    Create a simple for or foreach loop when you stream the page out.

    Or simply use a while( $result = $db->query($sqlStat ment)) {} loop to accomplish the same task.
    Code:
    <select 
    	id="fileNameComboBox"
    	onChange="runSomeCode();"
    >
    	<!-- add each file to drop down list -->
    <?php 
    	foreach ( $arrayOfFileNames as $yourActualFileName => $yourFileNameDescription ) { 
    ?>
    			<option value = "<?php echo $yourActualFileName; ?>"> <?php echo $yourFileNameDescription; ?> </option>
    <?php 
    	} 
    ?>
    </select>

    Comment

    Working...