Hi I'm nearly at the and of my quest here. I have implemented a script that splits articles into sub pages and makes link with article titles. Here it goes:

Code:
$colname_id = "-1";
if (isset($_GET['id'])) {
  $colname_id = $_GET['id'];
}
mysql_select_db($database_connAdmin, $connAdmin);
$query_id = sprintf("SELECT * FROM stories WHERE id = %s", GetSQLValueString($colname_id, "int"));
$id = mysql_query($query_id, $connAdmin) or die(mysql_error());
$row_id = mysql_fetch_assoc($id);
$totalRows_id = mysql_num_rows($id);
$row_idtext = $row_id['story_text'];
//filter aut HTML code
function article_titles($strings)
{
$GLOBALS['a_page_total']++;
$GLOBALS['a_titles'][$GLOBALS['a_page_total']] = preg_replace(array("/\"$/", "/^\"/"), array("",""), trim($strings[1]));
$result = "G" . ($GLOBALS['a_page_total']) . "";
return ($result);
}

function article_display($body)
{
global $colname_id;
$GLOBALS['a_titles'] = array();
$GLOBALS['a_page_total'] = 0;
// ** Replace fake page title tags with an index token and store the title in the a_titles global array.
$body = preg_replace_callback("/<[ ]*[Pp][Aa][Gg][Ee][ ]+[Tt][Ii][Tt][Ll][Ee][^=]*[=]([^>]*)>/", "article_titles", $body); 

if ($GLOBALS['a_page'] < 1) $GLOBALS['a_page'] = 1;
if ($GLOBALS['a_page'] > $GLOBALS['a_page_total']) $GLOBALS['a_page'] = $GLOBALS['a_page_total']; 

$a_title = $GLOBALS['a_titles'][$GLOBALS['a_page']-1]; 

// Shrink $body (containing the entire article text) to just the text on the page being displayed.
if ($GLOBALS['a_page'] == $GLOBALS['a_page_total'])
{
$token = "G{$GLOBALS['a_page']}";
$body = substr($body, strpos($body, $token)+strlen($token));
} else
{
$token = "G{$GLOBALS['a_page']}";
$token_b = sprintf("G%s", $GLOBALS['a_page']+1);
$body = substr($body, strpos($body, $token)+strlen($token), strpos($body, $token_b)-strlen($token_b));
} 

if ($GLOBALS['a_page'] < $GLOBALS['a_page_total'])
{
$next_title=$GLOBALS['a_titles'][$GLOBALS['a_page']+1];
} else
$next_title="";



if (($GLOBALS['a_page']<$GLOBALS['a_page_total']) && ($GLOBALS['a_page_total']))
{
$body .= sprintf("<p><div align=\"right\"><a href=\"{$_SERVER['PHP_SELF']}?id=$colname_id&a_page=%s\">Next Page%s</a></div>", $GLOBALS['a_page']+1, $next_title? " - $next_title":"");
} 

if ($GLOBALS['a_page_total']>1)
{
$body .= "<p><div class=\"H3\">Contents</div></p>"; 

$body .= "<p>";
for ($n=1; $n<=$GLOBALS['a_page_total']; $n++)
{
if ($n == $GLOBALS['a_page'])
{
$body .= sprintf("%s. %s<br>", $n, $GLOBALS['a_titles'][$n]);
} else
{
$body .= sprintf("%s. <a href=\"{$_SERVER['PHP_SELF']}?id=$colname_id&a_page=%s\">%s</a><br>", $n, $n, $GLOBALS['a_titles'][$n]);
}
}
$body .= "</p>";
}

echo str_replace("\n\n", "<p>", $body); 

echo "<br clear=all>";
} 

if (!isset($a_page)) $a_page=1;
echo "\n";
article_display
("$row_idtext");
echo "\n";
?>
My code correctly splits an article in an exact number of subpages and makes correct links to ich one of the subpages. The problem lies in article spliting which it's correct for the first and last page but in the middle pages does not split correctly. If an article is splited in four subpages in the second page apears the second page with the third page, in the third page apears the third and the fourth page.

I'm pulling my hair of for many hours now. If someone is so nice to give me a hand to find out a solution.

THX in advance