Can anyone help me with this problem?
Please what am i doing wrong? i write this code using CI in my controller and i have a view file am loading as well but is only the data that am able to get in not inserting it into the jqgrid table can anyone help??
class ML2 extends Controller{
var $gsm;
var $keyword = 'ml';
var $email_add;
var $firstname;
var $body;
var $per_page = 50;
function Ml2()
{
parent::Controller();
$this->load->model('Ml_model');
$this->load->model('sms_model_reseller');
//$this = get_instance();
$this->load->helper('url');
$this->load->library('session');
$this->config->item('base_url');
}
function index()
{
$data['title'] = 'ME & LECKY | TechClick Limited LongCode System';
$data['rows'] = $this->Ml_model->get_ml_data('per_page');
$data['content'] = $this->load->view('ml2_view', $data, TRUE);
$this->load->view('main', $data);
echo json_encode($data);
$page = $_GET['page']; // get the requested page
$limit = $_GET['rows']; // get how many rows we want to have into the grid
$sidx = $_GET['sidx']; // get index row - i.e. user click to sort
$sord = $_GET['sord']; // get the direction
if(!$sidx) $sidx =1; // connect to the database
$db = mysql_connect("localhost","root","")
or die("Connection Error: " . mysql_error());
mysql_select_db($database) or die("Error conecting to db.");
$result = $this->db->query("SELECT * AS numrow FROM ml");
$row = mysql_fetch_array($result,MYSQL_ASSOC);
$row = $result->row();
$count = $row->numrow;
$count = $row['count'];
if( $count >0 ) {
$total_pages = ceil($count/$limit);
}
else{
$total_pages = 0;
}
if ($page > $total_pages) $page=$total_pages;
$start = $limit*$page - $limit; // do not put $limit*($page - 1)
$result = $this->query("SELECT * FROM ml ORDER BY $numrow LIMIT $start $limit");
$sql = "SELECT id, gsm, email, firstname,body,date,time FROM ml,ORDER BY $sidx $sord LIMIT $start , $limit";
$data->page = $page;
$data->total = $total_pages;
$data->records = $count;
$i=0;
foreach ($result->result() as $nrow)
{//ID GSM EMAIL FIRSTNAME BODY DATE TIME
$data->nrow[$i]['id']=$nrow[id];
$data->nrow[$i]['cell']=array($nrow[id],$nrow[gsm],$nrow[email],$nrow[firstname],$nrow[body],$nrow[date_time]);
$i++;
}
echo json_encode($data);
}
}