SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Wizard
    Join Date
    Oct 2005
    Location
    London
    Posts
    1,678
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    why wont this logic work

    Could anyone tell me why this logic isnt working?

    PHP Code:
    if(!isset($_GET['s']) || isset($_GET['s']) && $_GET['s'] !='news') { 
      ?>
        <div id="footer_1">
        <?php
          
    }
          else if(!isset(
    $_GET['s']) || isset($_GET['s']) && $_GET['s'] !='author') { 
      
    ?>
        <div id="footer_1">
        <?php
          
    }
        else { 
        
    ?>
        <div id="footer">
        <?php
          
    }
        
    ?>
    its always getting set to footer_1. ......even when 's' is set and is not equal to author or news

  2. #2
    SitePoint Guru Ize's Avatar
    Join Date
    Nov 2005
    Location
    The Netherlands
    Posts
    808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try this:

    PHP Code:
    if (!isset ($_GET['s']) || ($_GET['s'] != 'news')) { 

  3. #3
    SitePoint Wizard
    Join Date
    Oct 2005
    Location
    London
    Posts
    1,678
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hi,

    no, now its always getting set to footer!

    PHP Code:
        <?php
        
    //hack to make footer behave on the new page
        
    if (!isset ($_GET['s']) || ($_GET['s'] != 'news')) { 
       
      
    ?>
        <div id="footer">
        <?php
          
    }
         elseif (!isset (
    $_GET['s']) || ($_GET['s'] != 'author')) { 
      
    ?>
        <div id="footer">
        <?php
          
    }
        else { 
        
    ?>
        <div id="footer_1">
        <?php
          
    }
        
    ?>

  4. #4
    SitePoint Guru Ize's Avatar
    Join Date
    Nov 2005
    Location
    The Netherlands
    Posts
    808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This, then:

    PHP Code:

    $s 
    = isset($_GET['s'])?$_GET['s']:'';
    if (
    $s != 'news') { 

  5. #5
    SitePoint Wizard
    Join Date
    Oct 2005
    Location
    London
    Posts
    1,678
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hi,

    no its still always getting set to footer:

    PHP Code:
    $s = isset($_GET['s'])?$_GET['s']:'';
        if ($s != 'news') { ?>
            <div id="footer">
          <?php
          
    }
          
        elseif (
    $s != 'author') { ?>
      <div id="footer">
      <?php
      
    }
      else {
      
    ?>
       <div id="footer_1">
        <?php
          
    }
          
    ?>
    author or news are definately in the $_GET ( $_GET 's' i mean) but its still getting set to footer......i dont get it. I dont really see why my original code didnt work

  6. #6
    SitePoint Guru Ize's Avatar
    Join Date
    Nov 2005
    Location
    The Netherlands
    Posts
    808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ah, so there are different cases?

    Why not try a switch statement?

  7. #7
    SitePoint Wizard
    Join Date
    Oct 2005
    Location
    London
    Posts
    1,678
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes i want footer_1 to be set if author or news is set in the $_GET.

    i dont think that would make any difference would it? I thought switch just replaced multiple if and elses? Also i dont really get how to use switch!!!

  8. #8
    Dinah-Moe Humm mudshark's Avatar
    Join Date
    Dec 2003
    Posts
    1,072
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $footer = ((isset($_GET['s'])) && $_GET['s'] == 'author' or $_GET['s'] == 'news') ? 'footer_1' 'footer';
    echo 
    '<div id="'.$footer.'">\n'
    How's that?

  9. #9
    SitePoint Wizard
    Join Date
    Oct 2005
    Location
    London
    Posts
    1,678
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hi,

    yes thats it thanks very much!

    Im a little worried that my or the code ize posted didnt work....i dont see why.......im going to look in to it.

    thanks to both of you


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
  •