Results 1 to 3 of 3

Thread: pagination

  1. #1
    Join Date
    Apr 2010
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question pagination

    Hi!
    I am a beginner in PHP and I have the following problem: site for movies with categories: comedy, horror, action and so on... the code for displaying the results is the same for all of the genres and I make the following:
    <a href="movies.php?category=comedy">COMEDY</a>
    and then:
    $index = (preg_match("//", $_GET['category'])) ? $_GET['category'] : 0;
    $sql = "SELECT * FROM movies WHERE category = '$index' ORDER BY movID DESC";
    It's okay so far BUT... for every genre, I have and pagination, and when try to go the next page, consider page 2 for genre comedy just nothing... I can't explain exactly... I just want to ask you some advise how to reuse the same code for all genres, and the pagination to work properly, some good tutorial or something else... if somebody is interesting in that I can show him the code... the site I am making is just for my personal training...
    PS: My english is nor very good, sorry about that please in the beginning of your answer rate my level of english(1-10) thanks

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,162
    Thanks
    263
    Thanked 690 Times in 678 Posts

    Default

    Your English is fine.


    I suggest using a loop like this:
    PHP Code:
    $genres = ('1','2','3',....,'X');
    foreach (
    $genres as $genre) {
      
    //insert your code here

    Also, you could use a variable called $genre and use input (like .../page.php?genre=action => $_GET['genre'] ), then use that information.

    Can you link to your page or how you want it to look? There are a lot of ways to do pagination.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. The Following User Says Thank You to djr33 For This Useful Post:

    panassonic (04-14-2010)

  4. #3
    Join Date
    Apr 2010
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Thanks djr33, I will try by that way, I hope it will work

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •