Web Analytics Made Easy -
StatCounter Navigation - CodingForum

Announcement

Collapse
No announcement yet.

Navigation

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Navigation

    Hi guys. I am very new to php and I would really appreciate if someone could help me create a very simple set of navigation buttons. Here's what I want to do. I want to create a page with two buttons, "Next" and "Previous". The page has a frame with a default page "page1.html". I want the navigation btton "next" to change the frame to pageX+1.html (eq., page2.html, page3.html, etc.) and the button "Previous" to do the opposite. Thank you in advance for your help.

  • #2
    maybe this would help

    PHP Code:
    <?php
        $tmp 
    explode('.'$_SERVER['PHP_SELF']);
        
    print_r($tmp);
        
    $page_nr substr($tmp[0], -1);
        if (
    is_int($page_nr) && $page_nr != 1) {
            echo 
    '<a href="page'.$page_nr-1.'.html">Prev</a>';
        }
        if (
    file_exists('page'.$page_nr+1.'.html')) {
            echo 
    '<a href="page'.$page_nr+1.'.html">Next</a>';
        }
    ?>
    Free php image upload script
    Personal web developing blog

    Comment


    • #3
      Thank you very much for the response but it does not seem to work because every time I try to load the page it gives me this error message:

      Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in /home/www/xxxxx.xxxxxx.com/index.php on line 6

      where line 6 would be:
      echo '<a href="page'.$page_nr-1.'.html">Prev</a>';

      Comment


      • #4
        try this one
        PHP Code:
        <?php
            $tmp 
        explode('.'$_SERVER['PHP_SELF']);
            
        print_r($tmp);
            
        $page_nr substr($tmp[0], -1);
            if (
        is_int($page_nr) && $page_nr != 1) {
                
        $prev_page_nr $page_nr+1;
                echo 
        '<a href="page'.$prev_page_nr.'.html">Prev</a>';
            }
            
        $new_page_nr $page_nr+1;
            if (
        file_exists('page'.$new_page_nr.'.html')) {
                echo 
        '<a href="page'.$new_page_nr.'.html">Next</a>';
            }
        ?>
        Free php image upload script
        Personal web developing blog

        Comment


        • #5
          ok this one seems to work but it does not happen in a frame so after the first click I lose the navigation bar.

          Comment


          • #6
            So put the PHP code in another file and imbed that file in a frame if that's what you want to do.

            Or were you expecting someone to write every line for you?

            Comment


            • #7
              target="iframe"? doesnt that fix it?

              Comment

              Working...
              X