need help

bradleyx

Member
Messages
108
Reaction score
1
Points
18
i need some help no matter what i am trying it doesnt work.

using codeigniter 2.0.2

i want to set up pagination for my website.

this is what i have in my crontroller:
Code:
  $config = array();
  $config["base_url"] = base_url() . "/credits";
  $config['total_rows'] = 200;
  $config['per_page'] = 2;
  $config["uri_segment"] = 3;
  $this->pagination->initialize($config);
  $page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
  $data["results"] = $this->credits_model->
  fetch_countries($config["per_page"], $page);
  $data["links"] = $this->pagination->create_links();


model:
Code:
  public function record_count() {
  return $this->db->count_all("sadmin_credits");
  }
  public function fetch_countries($limit, $start) {
  $this->db->limit($limit, $start);
  $query = $this->db->get("sadmin_credits");
  if ($query->num_rows() > 0) {
  foreach ($query->result() as $row) {
  $data[] = $row;
  }
  return $data;
  }
  return false;
  }

i need some help in getting to work. it shows the numbers but i click on the numbers it just shows the same results nothing changes.
it shows same results on first page instead of different records. need help fixing that.


btw i read the guide, tried google. followed everything nothing works just shows same page that it shows on the link.

this is the guide i used: http://www.sitepoint.com/pagination-with-codeigniter/
 

studio5

Member
Messages
33
Reaction score
2
Points
8
This may sound elementary, but did you connect to your mysql server?
<?php
$con=mysqli_connect("example.com","bradlyx","abc123","my_db");
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

$result = mysqli_query($con,"SELECT * FROM Persons");

while($row = mysqli_fetch_array($result)) {
echo $row['FirstName'] . " " . $row['LastName'];
echo "<br>";
}

mysqli_close($con);
?>
The CodeIgniter script was grabbing countries from a db, are you using a db to contain your credits in?
Seems like alot of extra lifting?
Have you tried to echo your results similar to the script above?
 
Last edited:
Top