CodeIgniter Forums
manual php to CI code - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: manual php to CI code (/showthread.php?tid=54533)



manual php to CI code - El Forum - 09-12-2012

[eluser]Beginers[/eluser]
Hi guys i wanna know what is the equivalent Codeigniter codes for this manual php..

please help. thanks is advance

Code:
<?php
class Autocomplete extends CI_Controller
{
    function getResult($title)
    {      
         $return_arr = array();
    
        $fetch = mysql_query("SELECT itemCode,itemDesc,itemHTS,itemECCN FROM items WHERE itemCode like'$title%' ORDER BY itemCode LIMIT 5");
    
        /* Retrieve and store in array the results of the query.*/
        while ($row = mysql_fetch_array($fetch, MYSQL_ASSOC)) {
    
            $row_array['itemCode']       = $row['itemCode'];
            $row_array['itemDesc']       = $row['itemDesc'];
            $row_array['itemHTS']          = $row['itemHTS'];
            $row_array['itemECCN']          = $row['itemECCN'];
            array_push( $return_arr, $row_array );
        }
    
        /* Toss back results as json encoded array. */
        echo json_encode($return_arr);
    }
}



manual php to CI code - El Forum - 09-13-2012

[eluser]xtremer360[/eluser]
I suggest reading the docs for codeigniter. Very detailed.


manual php to CI code - El Forum - 09-13-2012

[eluser]TWP Marketing[/eluser]
What you want is describe on these pages of the User Guide:

http://ellislab.com/codeigniter/user-guide/database/index.html

Yes, it is several pages of detailed descriptions on using the CI database class.