Results 1 to 5 of 5

Thread: PHP Tutorials

  1. #1
    Senior Member gss03's Avatar
    Join Date
    Jul 2003
    Location
    Scotland
    Posts
    725
    Thanks
    6
    Thanked
    28 times in 28 posts

    PHP Tutorials

    I want to make one of these menu systems in PHP whereby you get the link looking like www.blahblahblah.co.uk/index.php?a=whatever

    I've worked out I am using a switch statement...but it's not working
    switch code:
    PHP Code:
        <?php 
    $a 
    $HTTP_GET_VARS['var'];
    switch(
    $a) {
    case 
    "anchor":
    $output "anchor.php";
    break;
    case 
    "junior":
    $output "junior.php";
    break;
    case 
    "company":
    $output "company.php";
    break;
    case 
    "senior":
    $output "senior.php";
    break;
    default:
    $output "news.php";
    }

    ?>
    I don't get error pages....just there is no change to the page overall, it reloads with no change to any of the information I guess it's looping back to the default case ???? if so why?

    Any help or pointers to a tutorial would be a great help

    p.s if you are wondering about the naming scheme it's to replace my aging Boys Brigade site I did years ago.

  2. #2
    Sublime HEXUS.net
    Join Date
    Jul 2003
    Location
    The Void.. Floating
    Posts
    11,819
    Thanks
    213
    Thanked
    233 times in 160 posts
    • Stoo's system
      • Motherboard:
      • Mac Pro
      • CPU:
      • 2*Xeon 5450 @ 2.8GHz, 12MB Cache
      • Memory:
      • 32GB 1600MHz FBDIMM
      • Storage:
      • ~ 2.5TB + 4TB external array
      • Graphics card(s):
      • ATI Radeon HD 4870
      • Case:
      • Mac Pro
      • Operating System:
      • OS X 10.7
      • Monitor(s):
      • 24" Samsung 244T Black
      • Internet:
      • Zen Max Pro
    http://www.php.net has a whole bunch of information
    (\__/)
    (='.'=)
    (")_(")

  3. #3
    Sublime HEXUS.net
    Join Date
    Jul 2003
    Location
    The Void.. Floating
    Posts
    11,819
    Thanks
    213
    Thanked
    233 times in 160 posts
    • Stoo's system
      • Motherboard:
      • Mac Pro
      • CPU:
      • 2*Xeon 5450 @ 2.8GHz, 12MB Cache
      • Memory:
      • 32GB 1600MHz FBDIMM
      • Storage:
      • ~ 2.5TB + 4TB external array
      • Graphics card(s):
      • ATI Radeon HD 4870
      • Case:
      • Mac Pro
      • Operating System:
      • OS X 10.7
      • Monitor(s):
      • 24" Samsung 244T Black
      • Internet:
      • Zen Max Pro
    What uses $output by the way?

    As far as I can see you're not actually doing anything with the information in the variable?

    I'd create a function which calls the above, then use an include to get the information up on the page..

    doing a google for "php tutorials" does wonders too
    (\__/)
    (='.'=)
    (")_(")

  4. #4
    Senior Member Kezzer's Avatar
    Join Date
    Sep 2003
    Posts
    4,863
    Thanks
    12
    Thanked
    5 times in 5 posts
    I thought you had to use the $_GET global array although i've never used that one.

    Also if i remember correctly it would be quicker to just state the function as opposed to creating a function assigned to a variable and then calling it 'cause it would take longer then. Just say: switch($_GET['page'];) { then go into the actual parameters of the switch. For example, this is what mine looks like for the first 10 or so lines:

    PHP Code:
    <?php
    switch ($_GET['page']) 
    {

    case 
    'articles':
    include(
    'includes/articles.php');
    break;
    case 
    'read_article':
    include(
    'includes/read_article.php');
    break;

  5. #5
    Sublime HEXUS.net
    Join Date
    Jul 2003
    Location
    The Void.. Floating
    Posts
    11,819
    Thanks
    213
    Thanked
    233 times in 160 posts
    • Stoo's system
      • Motherboard:
      • Mac Pro
      • CPU:
      • 2*Xeon 5450 @ 2.8GHz, 12MB Cache
      • Memory:
      • 32GB 1600MHz FBDIMM
      • Storage:
      • ~ 2.5TB + 4TB external array
      • Graphics card(s):
      • ATI Radeon HD 4870
      • Case:
      • Mac Pro
      • Operating System:
      • OS X 10.7
      • Monitor(s):
      • 24" Samsung 244T Black
      • Internet:
      • Zen Max Pro
    yeah, it's still valid, but technically $_GET is the preferred useage now, the functions are just a hang-up from my c++ programming days (incidentally, for something as simple as this it really doesn't make that much difference which way you do it)
    (\__/)
    (='.'=)
    (")_(")

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Learning PHP
    By Craig in forum Software
    Replies: 11
    Last Post: 22-03-2004, 03:10 AM
  2. Creating databases using PHP?
    By Nemeliza in forum Software
    Replies: 10
    Last Post: 22-11-2003, 10:45 PM
  3. PHP to POST nuke migration
    By Ferral in forum Networking and Broadband
    Replies: 1
    Last Post: 30-10-2003, 08:13 PM
  4. PHP and MySQL
    By Kezzer in forum Software
    Replies: 4
    Last Post: 28-10-2003, 02:59 PM
  5. How to learn PHP
    By adwhitworth in forum Software
    Replies: 15
    Last Post: 15-09-2003, 03:51 PM

Posting Permissions

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