Title: Calling data to database
Last modified: August 31, 2016

---

# Calling data to database

 *  [mae48](https://wordpress.org/support/users/mae48/)
 * (@mae48)
 * [10 years ago](https://wordpress.org/support/topic/calling-data-to-database-1/)
 * Hi, I have a form provided with ID and Class…and I want them to call my product
   title using my function.php if possible.By the way, I want to make a dropdown,
   that’s why..
 * How can I do that??here is my code..
 * <label for=”promolist”>You selected this promo</label>
    <div class=”form-control”
   id=”promolist”>
 *  </div>

Viewing 1 replies (of 1 total)

 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [10 years ago](https://wordpress.org/support/topic/calling-data-to-database-1/#post-7298943)
 * WooCommerce products right? You want the product titles to appear as a dropdown
   select field, yes? But not all titles I would think, so what distinguishes the
   products in this list? A product category? Tag? Some other meta field?
 * Most of the code can be in functions.php, but unless there’s a filter to hook
   for the form HTML, something needs to be on the template, such as a template 
   tag (function) that outputs the dropdown HTML. There’s a specific way to override
   Woo templates, what to do can be found in WooThemes’ knowledge base.
 * In this template tag or function, first output the portion of dropdown HTML that
   doesn’t repeat, namely the `<select>` tag, and perhaps the first option that 
   just reads “Select…”. Now make a custom query for published product posts restricted
   by whatever category, tag, field, etc. Loop through the query results and in 
   each iteration output the `<option>` tag with appropriate attributes, the post/
   product title, and `</option>`. If you want the select field to reflect a previously
   saved value as the currently selected option, the WP `select()` function is a
   handy way to output the selected attribute.
 * After the loop completes, output the closing `</select>`.

Viewing 1 replies (of 1 total)

The topic ‘Calling data to database’ is closed to new replies.

## Tags

 * [database](https://wordpress.org/support/topic-tag/database/)
 * [dropdown](https://wordpress.org/support/topic-tag/dropdown/)

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 1 reply
 * 2 participants
 * Last reply from: [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * Last activity: [10 years ago](https://wordpress.org/support/topic/calling-data-to-database-1/#post-7298943)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
