Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You could iterate through the results that your query is currently generating and add the <code>Name</code> elements to an new array, like this:</p> <pre><code>$name_array = $this-&gt;db-&gt;query('SELECT DISTINCT Name from HWC')-&gt;result_array(); $typeahead_array = array(); foreach ($name_array as $name) { $typeahead_array[] = $name['Name']; } $data['typeahead'] = $typeahead_array; </code></pre> <hr> <p>Edit:</p> <p>To use the typeahead functionality in Bootstrap, the data source can be a list of strings, for example: <code>"Orange", "Apple", "Banana"</code></p> <p>You could assign the <code>$data['typeahead']</code> variable a string that is a list of options, pass it to the view and echo it to the relevant attribute.</p> <p><strong>Controller</strong></p> <p>The loop below will create a string variable that will contain all of the options for the typeahead. It adds quotation marks around each element and a comma at the end - so <code>Apple</code> would become <code>"Apple",</code>. It will then append each element to the string.</p> <pre><code>$name_array = $this-&gt;db-&gt;query('SELECT DISTINCT Name from HWC')-&gt;result_array(); $typeahead_string = ''; foreach ($name_array as $name) { $formatted_name = '"' . $name['Name'] . '", '; $typeahead_string .= $formatted_name; } $option_list = rtrim($typeahead_string, ","); //Strips the last comma and any whitespace from the end string $data['typeahead'] = $option_list; </code></pre> <p><strong>View</strong></p> <p>Your input in the view should look something similar to this, the important part being where the option list is echoed: <code>data-source="[&lt;?php echo $typeahead; ?&gt;]"</code></p> <pre><code>&lt;input type="text" data-provide="typeahead" data-items="4" data-source="[&lt;?php echo $typeahead; ?&gt;]"&gt; </code></pre> <p>Hopefully this helps!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload