Welcome Guest, Not a member yet? Register   Sign In
Creating a simple picture gallery
#1

[eluser]Unknown[/eluser]
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) :
Code:
<?php

class Picmodel extends Model {

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

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

My controller:
Code:
<?php

class Picture extends Controller {
    
    function Picture()
    {
        parent::Controller();
        $this->load->helper(array('form', 'url'));
    }
    function show_pic()
    {
        $this->load->model('picmodel','pics');        
        $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
#2

[eluser]sophistry[/eluser]
welcome to CI.

http://ellislab.com/codeigniter/user-gui...ation.html
#3

[eluser]Unknown[/eluser]
wow, TOO easy Tongue . Thanks!
#4

[eluser]llbbl[/eluser]
would like to see an example when you get it working




Theme © iAndrew 2016 - Forum software by © MyBB