Welcome Guest, Not a member yet? Register   Sign In
Two questions ( max query and displaying images )
#1

[eluser]Brovar[/eluser]
Hi guys!

I'm new to CodeIgniter, and while it's very cool to use, i've ran into some problems.

I am currently making a webcomic/blog. On my main page i want to display latest comic.
Here are my 2 questions regarding that issue:

1. Easiest way to do that would be to just get comic from database with max id. I actually managed to make it work, but it seems to be not optimal.

Here's the code i used in my model for that task:

Code:
public function get_comic
{

  $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();
}

Is it ok, or is there a better way to do that?

2. Next i want to post the image i got in my view. I store my images on the server, and i have ComicUrl column in comic table, which has entries like "images/1.jpg". I tried to use img() via html helper, but it looks like you can't use objects from array as url there. ATM i have no idea how to display that comic.

Any help would be appreciated!


Messages In This Thread
Two questions ( max query and displaying images ) - by El Forum - 02-24-2012, 02:21 PM
Two questions ( max query and displaying images ) - by El Forum - 02-27-2012, 12:36 AM
Two questions ( max query and displaying images ) - by El Forum - 02-27-2012, 09:23 AM



Theme © iAndrew 2016 - Forum software by © MyBB