Paging

az123ss

New Member
After 2 days of looking for an answer to my question I understand that I am not capable to solve my problem alone...
My idea is simple but the realization is harder ... I want to have a simple paging like this one http://www.imdb.com/news/top. I have learned that it can be done with php code but now I'm absolutely confused what codes should I write.
I create a MySQL DB , user but I dont know how to connect them to the site. Without that paging everything fails so please help me if you have any idea.
 

smoovo

New Member
First, why have you waited 2 days?... :eek: Second, I'm a big fan of IMDB, but no one cares...

OK, look on the address bar of the link to IMDB that you have posted, it says "...com/news/top" and after one click to next it becomes "...com/news/top?start=21", that means that when you are clicking the link it has a "GET" method used to send information.

name => start
value => 21

In this page, at its first lines of code, it has a page checker. This piece of code look for variable named "start" and its value.

PHP:
<?php

    if (!isset($_GET['start'])) {
        // Here comes the code that contact
        // your DB and pulling the information
        // for pages 1 to 20.
    } else {
        $start = $_GET['start'];
        $stop = $start+19;
        // And here comes the code that contact
        // your DB and pulling the information
        // for pages $start to $start+19.
        // In this case 21 to 40.
    }

?>

The link also been changing all the time. If you are clicking on next it tells a function to rewrite the link differently (to add 20 to the link => 21, 41, etc.).

If you are clicking the previous link another function will fire up and will rewrite the link for -20.

both sides, if there is no more pages will delete the anchor element around the link to prevent clicks.

- Good Luck. :)
 

az123ss

New Member
Thanks a lot ... But I am a new in the "bussines " :) and I have one more question. I really hoping that this question will be last. Now I have a problem with uploading images into MySQL. I know that we didn't actually add the image to the database. I have watched some video tutorials but i didn't find the answers there. In tutorial they were talking about classes and users and the php code was very very dificult to read and understanding. If you can suggest something simpler it would be great.
 
Top