SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Zealot m0h's Avatar
    Join Date
    Sep 2001
    Location
    Cairo, Egypt
    Posts
    190
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Multi-Purpose Page

    What is the best way to make a multi-purpose page?
    i also like to know how do i use more that one "IF"
    like :
    if (<condition>) { <do so and so>
    if (<condition2>) { <do somthing else>
    if (<condition3>) { <do ..........>
    } else { do xx ?>

    now i'm using this code
    PHP Code:
    <HTML>
    <HEAD>
    <TITLE> Multi-Purpose Page Outline </TITLE>
    </HEAD>
    <BODY>
    <?php if (<condition>) { ?>
    <!-- HTML content to display if <condition> is true -->
    <?php } else { ?>
    <!-- HTML content to display if <condition> is false -->
    <?php ?>
    </BODY>
    </HTML>
    Thanx

  2. #2
    SitePoint Wizard TWTCommish's Avatar
    Join Date
    Aug 1999
    Location
    Pittsburgh, PA, USA
    Posts
    3,910
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Simple!

    PHP Code:
    <html>
    <head>
    <title>Title</title>
    </head>

    <body>
    <?php
      
    if ($page == "home") {
        print 
    "Welcome to our site";
      } else if (
    $page == "help") {
        print 
    "This is our help page";
      } else {
        print 
    "Welcome to this page.";
      } 
    ?>
    </body>
    </html>

  3. #3
    SitePoint Zealot m0h's Avatar
    Join Date
    Sep 2001
    Location
    Cairo, Egypt
    Posts
    190
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanx alot!
    I remember that it was some thing like this, but I used "elseif" not "else if"

    Any way thanx again

  4. #4
    SitePoint Columnist Skunk's Avatar
    Join Date
    Jan 2001
    Location
    Lawrence, Kansas
    Posts
    2,066
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Another way to do it is with the switch statement:
    PHP Code:
    <html>
    <head>
    <title>Title</title>
    </head>

    <body>
    <?php
    switch($page) {
    case 
    'home':
        print 
    "Welcome to our site";
        break;
    case 
    'help':
        print 
    "This is our help page";
        break;
    default:
        print 
    "Welcome to this page.";

    ?>
    </body>
    </html>

  5. #5
    SitePoint Wizard Defender1's Avatar
    Join Date
    Apr 2001
    Location
    My Computer
    Posts
    2,808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yea, switch statements are really useful when you need to do a lot of conditionals.
    Defender's Designs
    I'm Getting Married!

    Not-so-patiently awaiting Harry Potter Book 7 *sigh*

  6. #6
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by m0h
    Thanx alot!
    I remember that it was some thing like this, but I used "elseif" not "else if"
    They will both produce the same result

    http://www.php.net/manual/en/control...res.elseif.php

    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature

  7. #7
    SitePoint Zealot m0h's Avatar
    Join Date
    Sep 2001
    Location
    Cairo, Egypt
    Posts
    190
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanx every one

    Can some one post a link to some where that have more info about the switch statement?

  8. #8
    SitePoint Zealot m0h's Avatar
    Join Date
    Sep 2001
    Location
    Cairo, Egypt
    Posts
    190
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    One more thing
    I'm using

    switch($do) {
    case 'check':

    so the url is index.php?check
    i want to add some values to the url
    Ex. index.php?check?email=you@there.now?code=34223
    how can i do this? if i used that url it will take me to the default page!
    can i use somthing like case 'check*': ?

  9. #9
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here is some info on switch:
    http://www.php.net/manual/en/control...res.switch.php

    If you want to put more than one variable in the URL use &. For example:

    http://mysite.com/script.php?name=sean&age=19

    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature

  10. #10
    SitePoint Zealot m0h's Avatar
    Join Date
    Sep 2001
    Location
    Cairo, Egypt
    Posts
    190
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't know what i was going to do without you!
    Thanx alot every one, and thanx seanf


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
  •