Zend - The PHP Company




Forms

Add Code


Auto fill drop down tables from a Access database  

Type: code fragment
Added by: gravestone
Entered: 26/04/2000
Last modified: 08/12/1999
Rating: **** (4 votes)
Views: 15626
Using this quick snippet you can auto fill your drop down boxes easily using microsoft access.


<?php
function display_data($usertable,$fieldname) {
    
$db = new DB_local;
    
$queryst "SELECT * FROM $usertable";
    
$result $db->query($queryst);
    
$number odbc_num_rows($result);

      if( 
odbc_fetch_row($result1) ) {
    do {
    
$var odbc_result($result,"$fieldname");
    print 
"<option value='$var'>$var</option><br>n";
    } while ( 
odbc_fetch_row($result) );
      }    else {
        print(
"No data in the record set");
    }
}   

?>


Usage Example


Put this into your html between <select>
</select> tags.
<? display_data('MyTableName','MyColumnName'); ?>


Rate This Script





Search



This Category All Categories