Note that there are some explanatory texts on larger screens.

plurals
  1. POautocomplete difficultes on getting the data from database
    primarykey
    data
    text
    <p>hi guys i have a problem on showing the data when i input any letters no data would complete the task so it doesn't get any data from the database </p> <p>Controller</p> <pre><code>&lt;?php //birds.php class Birds extends CI_Controller { function index() { $this-&gt;load-&gt;view('birds_view'); } function get_birds() { $this-&gt;load-&gt;model('birds_model'); if (!isset($_GET['term'])) { $q = strtolower($this-&gt;input-&gt;get('term')); $this-&gt;birds_model-&gt;get_bird($q); } } } </code></pre> <p>--------------------Model</p> <pre><code>//birds_model.php (Array of Strings) class Birds_model extends CI_Model { function get_bird($q) { $this-&gt;db-&gt;select('birds'); $this-&gt;db-&gt;like('birds', $q, 'after'); $query = $this-&gt;db-&gt;get('birds'); if ($query-&gt;num_rows &gt; 0) { foreach ($query-&gt;result_array() as $row) { $row_set[] = htmlentities(stripslashes($row['birds'])); //build an array } echo json_encode($row_set); //format the array into json data } } } </code></pre> <p>--------------------------------------View</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;link href="css/jquery-ui.css"&gt; &lt;script src= "http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" type= "text/javascript"&gt;&lt;/script&gt; &lt;script src="js/jquery-ui.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(document).ready(function(){ $("#birds").autocomplete({ source: "birds/get_birds" // path to the get_birds method }); }); &lt;/script&gt; &lt;title&gt;&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;form&gt; &lt;input id="birds" type="text"&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Here is my Database</p> <pre><code>CREATE TABLE birds ( id INT NOT NULL AUTO_INCREMENT, bird VARCHAR(50), aka VARCHAR(50), PRIMARY KEY (id) ) ENGINE = MYISAM ; INSERT INTO birds (id, bird, aka) VALUES (1, "Great Bittern", "Botaurus stellaris"), (2, "Little Grebe", "Tachybaptus ruficollis"), (3, "Black-necked Grebe", "Podiceps nigricollis"), (4, "Little Bittern", "Ixobrychus minutus"), (5, "Black-crowned Night Heron", "Nycticorax nycticorax"), (6, "Purple Heron", "Ardea purpurea"), (7, "White Stork", "Ciconia ciconia"), (8, "Spoonbill", "Platalea leucorodia"), (9, "Red-crested Pochard", "Netta rufina"), (10, "Common Eider", "Somateria mollissima"), (11, "Red Kite", "Milvus milvus"), (12, "Hen Harrier", "Circus cyaneus"), (13, "Montagu's Harrier", "Circus pygargus"), (14, "Black Grouse", "Tetrao tetrix"), (15, "Grey Partridge", "Perdix perdix"), (16, "Spotted Crake", "Porzana porzana"), (17, "Corncrake", "Crex crex"), (18, "Common Crane", "Grus grus"), (19, "Avocet", "Recurvirostra avosetta"), (20, "Stone Curlew", "Burhinus oedicnemus"); </code></pre> <p>my database name is birds my table name is birds my problem is when ever i it does not found any of database</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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