Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: Categories Page

  1. #1
    Regular Coder stevenmw's Avatar
    Join Date
    Jun 2007
    Location
    OK
    Posts
    497
    Thanks
    27
    Thanked 31 Times in 31 Posts

    Categories Page

    I'm working on something similar to a news system. I've got a database table storing a list of categories.

    Ifs any one knows where I can find a tutorial, or can just plain help that'd be amazing.


    I'm trying to build a page that generates a list of articles under one category. Each time a category link is clicked they are taken to this page, and only articles under the clicked category are visible.

    I've written a display file that checks a single category, and displays it. I'm trying to make a display that works for all categories....

  • #2
    Regular Coder seco's Avatar
    Join Date
    Nov 2008
    Location
    Oregon
    Posts
    687
    Thanks
    6
    Thanked 79 Times in 77 Posts

  • #3
    Regular Coder funnymoney's Avatar
    Join Date
    Aug 2007
    Posts
    364
    Thanks
    17
    Thanked 24 Times in 24 Posts
    Quote Originally Posted by stevenmw View Post
    I've written a display file that checks a single category, and displays it. I'm trying to make a display that works for all categories....
    If you can post your code maybe we could help you more.

    Usually links are accessed by $_GET or $_POST PHP predefined variables. $_GET variable, for example, is set when you click on link that looks something like this

    PHP Code:
    <a href="index.php?category=home">Home</a>
    <
    a href="index.php?category=about-us">About Us</a>
    <
    a href="index.php?category=contact">Contact</a
    When you click on that link you index.php with code below should display info based on the link you clicked

    PHP Code:
     if (isset($_GET['category'])) {
      switch (
    $_GET['category']) {
      case 
    "home":
       
    $page "home";
      break;
      case 
    "about-us":
       
    $page "about-us";
      break;
      case 
    "contact":
       
    $page "contact";
      break;
      default:
       
    $page "home";
      break;
      }
     }
    else {
     
    $page "home";
    }

    print 
    $page
    now you can use $page variable to display different categories based on $page value


  •  

    Posting Permissions

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