(07-12-2016, 09:18 AM)rtenny Wrote: (07-12-2016, 07:34 AM)davy_yg Wrote: Hello, I am trying to show data in here but have not been successful yet. controllers/cpages.php PHP Code:public function pcategories() { $this->Mpages->retrieve_parentctg(); $data['ctgparent_name'] = $this->Mpages->retrieve_parentctg(); $data['ctgparent_description'] = $this->Mpages->retrieve_parentctg(); $this->load->view('pcategories', $data); } views/pcategories.php PHP Code:<div class="widget-box"> <div class="widget-title"><h5>Parent Categories</h5></div> <div class="widget-content"> <table border="0" style="width: 100%; height: 90px;"> <tr> <td>PARENT NAME</td> <td>DESCRIPTION</td> <td>EDIT</td> <td>DELETE</td> </td> <tr> <td>Mens</td> <td><?php echo $ctgparent_name; ?></td> <td><button type="button" class="edit" onclick="location.href='<?php echo site_url('cpages/editparentctg'); ?>';">EDIT</button></td> <td><button type="button" class="delete" href="adminform.php">DELETE</button></td> </td> <tr> <td>Womens</td> <td><?php echo $ctgparent_description; ?></td> <td><button type="button" class="edit" onclick="location.href='<?php echo site_url('cpages/addparentctg'); ?>';">EDIT</button></td> <td><button type="button" class="delete" href="adminform.php">DELETE</button></td> </td> </table> </div> </div> The Result: A PHP Error was encountered Severity: Notice Message: Array to string conversion Filename: views/pcategories.php Line Number: 54 Backtrace: File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyGiondaCI\application\views\pcategories.php Line: 54 Function: _error_handler File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyGiondaCI\application\controllers\Cpages.php Line: 46 Function: view File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyGiondaCI\index.php Line: 315 Function: require_once Array Womens A PHP Error was encountered Severity: Notice Message: Array to string conversion Filename: views/pcategories.php Line Number: 60 Backtrace: File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyGiondaCI\application\views\pcategories.php Line: 60 Function: _error_handler File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyGiondaCI\application\controllers\Cpages.php Line: 46 Function: view File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyGiondaCI\index.php Line: 315 Function: require_once SQL DATABASE - TABLE: menu_parent ctgparent_name ctgp_no ctgparent_description Men 0 Description How to fix the error so that I can see the result? I think your function $this->Mpages->retrieve_parentctg(); is return an array rather then a plain string.
(07-12-2016, 07:34 AM)davy_yg Wrote: Hello, I am trying to show data in here but have not been successful yet. controllers/cpages.php PHP Code:public function pcategories() { $this->Mpages->retrieve_parentctg(); $data['ctgparent_name'] = $this->Mpages->retrieve_parentctg(); $data['ctgparent_description'] = $this->Mpages->retrieve_parentctg(); $this->load->view('pcategories', $data); } views/pcategories.php PHP Code:<div class="widget-box"> <div class="widget-title"><h5>Parent Categories</h5></div> <div class="widget-content"> <table border="0" style="width: 100%; height: 90px;"> <tr> <td>PARENT NAME</td> <td>DESCRIPTION</td> <td>EDIT</td> <td>DELETE</td> </td> <tr> <td>Mens</td> <td><?php echo $ctgparent_name; ?></td> <td><button type="button" class="edit" onclick="location.href='<?php echo site_url('cpages/editparentctg'); ?>';">EDIT</button></td> <td><button type="button" class="delete" href="adminform.php">DELETE</button></td> </td> <tr> <td>Womens</td> <td><?php echo $ctgparent_description; ?></td> <td><button type="button" class="edit" onclick="location.href='<?php echo site_url('cpages/addparentctg'); ?>';">EDIT</button></td> <td><button type="button" class="delete" href="adminform.php">DELETE</button></td> </td> </table> </div> </div> The Result: A PHP Error was encountered Severity: Notice Message: Array to string conversion Filename: views/pcategories.php Line Number: 54 Backtrace: File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyGiondaCI\application\views\pcategories.php Line: 54 Function: _error_handler File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyGiondaCI\application\controllers\Cpages.php Line: 46 Function: view File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyGiondaCI\index.php Line: 315 Function: require_once Array Womens A PHP Error was encountered Severity: Notice Message: Array to string conversion Filename: views/pcategories.php Line Number: 60 Backtrace: File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyGiondaCI\application\views\pcategories.php Line: 60 Function: _error_handler File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyGiondaCI\application\controllers\Cpages.php Line: 46 Function: view File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyGiondaCI\index.php Line: 315 Function: require_once SQL DATABASE - TABLE: menu_parent ctgparent_name ctgp_no ctgparent_description Men 0 Description How to fix the error so that I can see the result?
public function pcategories() { $this->Mpages->retrieve_parentctg(); $data['ctgparent_name'] = $this->Mpages->retrieve_parentctg(); $data['ctgparent_description'] = $this->Mpages->retrieve_parentctg(); $this->load->view('pcategories', $data); }
<div class="widget-box"> <div class="widget-title"><h5>Parent Categories</h5></div> <div class="widget-content"> <table border="0" style="width: 100%; height: 90px;"> <tr> <td>PARENT NAME</td> <td>DESCRIPTION</td> <td>EDIT</td> <td>DELETE</td> </td> <tr> <td>Mens</td> <td><?php echo $ctgparent_name; ?></td> <td><button type="button" class="edit" onclick="location.href='<?php echo site_url('cpages/editparentctg'); ?>';">EDIT</button></td> <td><button type="button" class="delete" href="adminform.php">DELETE</button></td> </td> <tr> <td>Womens</td> <td><?php echo $ctgparent_description; ?></td> <td><button type="button" class="edit" onclick="location.href='<?php echo site_url('cpages/addparentctg'); ?>';">EDIT</button></td> <td><button type="button" class="delete" href="adminform.php">DELETE</button></td> </td> </table> </div> </div>
public function retrieve_parentctg() { $query = $this->db->get('menu_parent'); return $query->result(); }