[eluser]Kraig[/eluser]
I am having some issues displaying the pagination with my query results. The results were working how they were supposed too, but not when I try to add CI pagination. The pagination library and url helper are loaded in the constructor
My Model:
Code:
public function cat_page($limit, $start, $catID)
{
if($catID == 0){
$query = $this->db->query('SELECT * FROM upload LIMIT '.$limit.', '.$start);
}else{
$query = $this->db->query('SELECT * FROM upload WHERE category = '.$catID.' LIMIT '.$limit.', '.$start);
}
$val = $query->result_array();
$this->num_rows = $query->num_rows;
if ($this->num_rows() > 0) {
foreach ($query->result() as $row) {
$data[] = $row;
}
return $data;
}
return false;
}
My home controller function being called:
Code:
public function catSelector()
{
$this->catID = $_GET['cat'];
// Pagination!!!
$config = array();
$config["base_url"] = base_url() . "home/";
$config["total_rows"] = $this->membership_model->num_rows;
$config["per_page"] = 5;
$config["uri_segment"] = 3;
$this->pagination->initialize($config);
$page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
$data["results"] = $this->membership_model->
cat_page($config["per_page"], $page, $this->catID);
$data["links"] = $this->pagination->create_links();
echo '<table cellspacing="0" cellpadding="0">
<tr>
<th width="50%">File Name:</th>
<th width="30%">File Size:</th>
<th>Download Link:</th>
</tr>';
$c = true;
foreach($data["results"] as $files){
echo '<tr'.(($c = !$c)?' class="odd"':'').">
<td>$files[name]</td>
<td>$files[size]</td>
<td><a href='$files[location]'>Download</a></td>
</tr>";
}
echo '</table><br ';
$this->load->view("home", $data);
}
I'm also having an issue with the the last line of the controller function ($this->load->view("home", $data)
.
My View: An Ajax feature that grabs the uploads based on category. This works....just not with the new editions of the pagination
Code:
......
[removed]
function showUser(str) {
if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else {// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
document.getElementById("tars")[removed]=xmlhttp.responseText;
}
}
xmlhttp.open("GET","home/catSelector?cat="+str,true);
xmlhttp.onload = table_design;
xmlhttp.send();
}
[removed]
.......
This is my home page and so in my index() function I load a template..wont that cause re-directs?. Does it look like I'm on the right track?? Thanks for your help!!