• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Creating a simple picture gallery

Hi everyone,

I am new to using code igniter, but I have been coding in PHP for a few years. I am making my first website and have come across a little problem.

I am trying to create this really simple photo gallery. What I need is a view (show_pic) that displays 10 images along with comments etc. I have created a page where a user can upload an image and save it to my server, and I can also display the images saved. What I am trying to achieve is to get 10 images on a page, get a user to click "next" or what-not and then display the next 10 images. If no more images are available then the next button is no longer displayed.

So far I have a model which gets the pictures (testing with just 2 images per page right now) :

class Picmodel extends Model {

    var $filename   = '';
    var $description = '';
    var $date    = '';

    function Picmodel()
        // Call the Model constructor
    function get_last_two_entries()
        $query = $this->db->get('pictures', 2, 1);
        return $query->result();
} >?

My controller:

class Picture extends Controller {
    function Picture()
        $this->load->helper(array('form', 'url'));
    function show_pic()
        $data['query'] = $this->pics->get_last_two_entries();
        $data['title'] = "Pictures";
        $data['heading'] = "Pictures";            
        $this->load->view('picture_view', $data);

And view simply grabs the data array and posts the first two pictures.

I am stuck at the "Next" button and I am not really sure how to call the same function - show_pic() - and ask for the next 2 pictures.

Any help would be really appreciated, thanks!

JP Levac

welcome to CI.


wow, TOO easy Tongue . Thanks!

would like to see an example when you get it working

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.