Welcome Guest, Not a member yet? Register   Sign In
Pagination using ajax in codeigniter 4
#3

Well then; i will use the default pagination which comes with codeigniter 4 but i really do need assistance as the tutorials am seeing online, pagination is created by accessing the model directly like so.

PHP Code:
$this->model->paginate(5
What if i have a custom query in StockModel.php

PHP Code:
public function stockphotopagination($where) {
 $builder $this->db->table("stock_photos")
  ->select('photo_name')
  ->where($where)
  ->get()
  ->getResultArray();


And in the StockController.php

PHP Code:
public function home() {
  $model = new StockModel();
  $where = [
   "deletion" "no",
   "display" => "yes"
  ];
  $query $model->stockphotopagination($where);
  $data['results'] = $query;
  echo view('views/home'$data);



And in home.php view:

PHP Code:
foreach($results as $row) {
  echo $row['
  photo_name'
]. '<br>';


How do i create pagination for this?
Reply


Messages In This Thread
RE: Pagination using ajax in codeigniter 4 - by coderscvoen - 06-07-2021, 12:37 AM



Theme © iAndrew 2016 - Forum software by © MyBB