PDA

View Full Version : Navigation


amthgy
09-26-2006, 10:47 AM
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.:o

kreoton
09-26-2006, 11:06 AM
maybe this would help

<?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>';
}
?>

amthgy
09-26-2006, 11:17 AM
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>';
:confused:

kreoton
09-26-2006, 11:25 AM
try this one
<?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>';
}
?>

amthgy
09-26-2006, 03:21 PM
ok this one seems to work but it does not happen in a frame so after the first click I lose the navigation bar.

Fumigator
09-26-2006, 05:44 PM
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?

rafiki
09-26-2006, 11:01 PM
target="iframe"? doesnt that fix it?