www.webdeveloper.com
Results 1 to 2 of 2

Thread: Autocomplete Form From Database?

  1. #1
    Join Date
    Apr 2011
    Posts
    16

    Autocomplete Form From Database?

    I am working in wordpress and need to create an autocomplete form.
    Using php and javascript (if it is necessary to be done that way, maybe just php and html?) I need to be able to call a db file on the wordpress server that will automatically populate the autocomplete box.

    Any help within the next couple of hours would be awesome!

  2. #2
    Join Date
    Apr 2011
    Posts
    16
    This is the code currently being used to populate a simple dropdown list, being populated by the db file:

    Code:
    	<?php
    		global $wpdb;
    		$depts = $wpdb->get_results( "SELECT * FROM departments ORDER BY department_name ASC" );
    		echo '<select>';
    
    		foreach($depts as $row) {
    			echo '<option name="select_dept" value="'.$row->department_id.'">'.$row->department_name.'</option>';
    		}
    		echo '</select>';
    	?>
    Thanks again.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles