[eluser]Brovar[/eluser]
Heya.
I'm making a webcomic site, and i've run into a problem. I'm displaying comics, and you can browse between then as in every site that type. The problem is, that displaying latest comic works fine, but switching won't work. Here's the code:
Model:
Code:
<?php
class Comic_model extends CI_Model {
public function __construct()
{
$this->load->database();
}
public function get_comic($id = FALSE)
{
if ($id == FALSE)
{
$this->db->select_max('ComicId');
$query = $this->db->get('comic');
$max = $query->row_array();
$maxx = $max['ComicId'];
$this->db->where('ComicId', $maxx);
$query = $this->db->get('comic');
return $query->row_array();
}
else
{
$query = $this->db->get_where('comic', array('ComicId' => $id));
return $query->row_array();
}
}
Controller:
Code:
<?php
class Comic extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->load->model('comic_model');
}
public function index($id = FALSE)
{
$this->load->helper('url');
$this->load->helper('html');
$data['comic'] = $this->comic_model->get_comic($id);
$this->load->view('templates/header');
$this->load->view('templates/main');
$this->load->view('comic', $data);
$this->load->view('templates/sidebar');
$this->load->view('templates/footer');
}
}
View:
Code:
<div id="splash"><img src = "<?php echo $comic['ComicUrl'] ?>" height = "400" width = "600"></div>
<div id="comicmenu">
<ul>
<li><?php echo anchor('comic',img('images/arrow_left2.jpg'));?></li>
<li><?php echo anchor('comic/index/8',img('images/arrow_left.jpg'));?></li>
<li><?php echo anchor('comic/index/9',img('images/arrow_right.jpg'));?></li>
<li><?php echo anchor('comic',img('images/arrow_right2.jpg'));?></li>
<?php echo $comic['ComicUrl'];?>
</ul>
</div>
As you see, if there is no id present, it just takes latest entry into database via get_max and displays it. Otherwise it returns an entry with corresponding id. The links are hardcoded for testing purposes.
The problem is, that when i go through webcomic/comic it works fine, but if i use webcomic/comic/index or webcomic/comic/index/$id it won't display the image. Curious thing is that proper database entry is actually passed to view. I double checked it via echo and the end of the view, and also if i go to source code, it actually shows identical img src as when going without id ( but of course with different entry ).
Any ideas?