Hello ?
i am not too sure what type of coding web language i need to try and do this but in my website i have hundreds of different pages that i would like to link together with a simple Next Page and Previous Page link on each web page ?
i have searched everywhere for a method to try and do this but i have had no luck finding anything ?
i would like to find a way to add a functional Next Page and Previous Page link at the bottom of each webpage, but is there a way for the code to link to the next page automatically rather than me typing each one in manually?
PS: all of the webpages that need to be linked are numbered in order, ex) page1.php, page2.php, page3.php etc ?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>Basic HTML</title>
<?php
function curPageName() {
return substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],"/")+1);
}
preg_match('/page(d+).php$/', curPageName(), $match);
echo '<link rel="prev" href="page' . ($match[1] - 1) . '.php">' . "n";
echo '<link rel="next" href="page' . ($match[1] + 1) . '.php">' . "n";
?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript">
</script>
<style type="text/css">
div a {margin:0 3px;}
</style>
</head>
<body>
<div>
<?php
echo '<a href="page' . ($match[1] - 1) . '.php">previous</a>';
echo '<a href="page' . ($match[1] + 1) . '.php">next</a>';
?>
</div>
</body>
</html>
Don't forget limit checking!<?php
function curPageName() {
return substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],"/")+1);
}
preg_match('/page(d+). php$/', curPageName(), $match);
echo '<link rel="prev" href="page' . ($match[1] - 1) . '.php">' . "n";
echo '<link rel="next" href="page' . ($match[1] + 1) . '.php">' . "n";
?>
[/QUOTE]
<div>
<?php
echo '<a href="page' . ($match[1] - 1) . '.php">previous</a>';
echo '<a href="page' . ($match[1] + 1) . '.php">next</a>';
?>
</div>
[/QUOTE]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>Basic HTML</title>
<?php
$lowest=10;
$highest=100;
function curPageName() {
return substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],"/")+1);
}
preg_match('/page(d+).php$/', curPageName(), $match);
if($match[1]>$lowest) {echo '<link rel="prev" href="page' . ($match[1] - 1) . '.php">' . "n";}
if($match[1]<$highest) {echo '<link rel="next" href="page' . ($match[1] + 1) . '.php">' . "n";}
?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript">
</script>
<style type="text/css">
div a {margin:0 3px;}
</style>
</head>
<body>
<div>
<?php
if($match[1]>$lowest) {echo '<a href="page' . ($match[1] - 1) . '.php">previous</a>';}
if($match[1]<$highest) {echo '<a href="page' . ($match[1] + 1) . '.php">next</a>';}
?>
</div>
</body>
</html>
[code=php]if($match[1]>$lowest) {echo '<a href="jockpage.php5?dj=$dj;&page=' . ($match[1] - 1) . '"style="font-weight:bold; text-decoration:underline;"><< newer 6 entries</a>';}
<b> | </b>
if($match[1]<$highest) {echo '<a href="jockpage.php5?dj=$dj;&page=' . ($match[1] + 1) . '"style="font-weight:bold; text-decoration:underline;">previous 6 entries >></a>';}
[/code]
if($match>$lowest) {echo '<a href="jockpage.php5?dj=' . $dj . '&amp;page=' . ($match[1] - 1) . '"style="font-weight:bold; text-decoration:underline;"><< newer 6 entries</a>';}
if($match<$highest) {echo '<a href="jockpage.php5?dj=' . $dj . '&amp;page=' . ($match[1] + 1) . '"style="font-weight:bold; text-decoration:underline;">previous 6 entries >></a>';}
[code=php]<?
$sql = "SELECT * FROM mfoland_djpage
.JockSite
WHERE dj
= '$dj' ORDER BY time ASC LIMIT 1";
$sql_result = mysql_query($sql,$connection);while ($row = mysql_fetch_array($sql_result))
{$page = $row["page"];$title = $row["title"];$body = $row["body"];$time = $row["time"];?>[/code]
[CODE]<?php
if($match[1]<$highest) {echo '<a href="book' . ($match[1] + 1) . '.php">Next</a>';}
?>[/CODE]
and this at the bottem of the page where I wish the next and Previous links to be: [CODE]<?php
if($match[1]>$lowest) {echo '<a href="page' . ($match[1] - 1) . '.php">previous</a>';}
if($match[1]<$highest) {echo '<a href="page' . ($match[1] + 1) . '.php">next</a>';}
?>[/CODE]
0.1.9 — BETA 5.13