Hullo there!

I'm using the code you can see below to create a news system for adding/editing/deleting news, and I'm actually using a text file instead of a database (because that was the challenge...). The code is not mine though and being quite new to PHP I'm now quite lost on how to switch pages, so that the page views max 10 news items and then breaks the rest into page two. Any help is appreciated, thanks for reading!

PHP Code:
<?
if($action == "edit" && isset($HTTP_POST_VARS['password'])) {
    if(
$HTTP_POST_VARS['password'] == "edittest") {
        
$line $HTTP_POST_VARS['date'] . "|" $HTTP_POST_VARS['name'];
        
$line .= "|" $HTTP_POST_VARS['news'];
        
$line str_replace("\r\n","<BR>",$line);
        
$line .= "\r\n";
        
$data file('news.txt');
        
$data[$id] = $line;
        
reset($data);
        
$fp fopen('news.txt','w');
        foreach(
$data as $element) {
            
fwrite($fp$element);
        }
        
fclose($fp);
        echo 
"News Edited!<BR><BR>\n";
        echo 
"<a href=\"$PHP_SELF\">Go Back</a>\n";
        exit;
    } else {
        echo 
"Wrong password!\n";
        exit;
    }
}
if(
$action == "edit") {
    
$data file('news.txt');
    
$element trim($data[$id]);
    
$pieces explode("|"$element);
    
$news str_replace("<BR/>","\r\n",$pieces[2]);
    echo 
"Make the changes you would like and press save.<BR/>\n";
    echo 
"<FORM ACTION=\"$PHP_SELF?action=edit\" METHOD=\"POST\" NAME=\"editform\">\n";
    echo 
"Name:<BR/>\n";
    echo 
"<INPUT TYPE=\"text\" SIZE=\"30\" NAME=\"name\" value=\"".$pieces[1]."\"><BR/>\n";
    echo 
"The News:<BR>\n";
    echo 
"<TEXTAREA NAME=\"news\" COLS=\"40\" ROWS=\"5\">".$news."</TEXTAREA><BR><BR>\n";
    echo 
"Password:<BR/>\n";
    echo 
"<INPUT TYPE=\"password\" SIZE=\"30\" NAME=\"password\"><BR/>\n";
    echo 
"<INPUT TYPE=\"hidden\" NAME=\"date\" VALUE=\"".$pieces[0]."\">\n";
    echo 
"<INPUT TYPE=\"hidden\" NAME=\"id\" VALUE=\"$id\">\n";
    echo 
"<INPUT TYPE=\"submit\" NAME=\"submit\" VALUE=\"Save\"><BR>\n";
    echo 
"</FORM>\n";
    exit;
}
if(
$action == "delete" && isset($HTTP_POST_VARS['password'])) {
    if(
$HTTP_POST_VARS['password'] == "deletetest") {
        
$data file('news.txt');
        
array_splice($data,$id,1);
        
$fp fopen('news.txt','w');
        foreach(
$data as $element) {
            
fwrite($fp$element);
        }
        
fclose($fp);    
        echo 
"Item deleted!<BR/><BR/>\n";    
        echo 
"<a href=\"$PHP_SELF\">Go Back</a>\n";
        exit;
    } else {
        echo 
"Wrong password!\n";
        exit;
    }
}
if(
$action == "delete") {
    echo 
"<H2>You are about to delete the following news item.</H2>\n";
    
$data file('news.txt');
    
$element trim($data[$id]);
    
$pieces explode("|"$element);
    echo 
$pieces[2] . "<BR/>" "<b>Posted by " $pieces[1] . " on " $pieces[0] . "</b>\n";
    echo 
"<BR/><BR/>\n";
    echo 
"Are you sure you want to delete this news item? If so, enter the password and click on Delete.<BR>\n";
    echo 
"<FORM ACTION=\"$PHP_SELF?action=delete\" METHOD=\"POST\" NAME=\"deleteform\">\n";
    echo 
"Password:<BR/>\n";
    echo 
"<INPUT TYPE=\"password\" SIZE=\"30\" NAME=\"password\"><BR/>\n";
    echo 
"<INPUT TYPE=\"hidden\" NAME=\"id\" VALUE=\"$id\">\n";
    echo 
"<INPUT TYPE=\"submit\" NAME=\"submit\" VALUE=\"Delete\"><BR/>\n";
    echo 
"</FORM>\n";
    exit;
}


echo 
"<H1><u>Current News</u></H1>\n";
$data file('news.txt');
foreach(
$data as $key=>$element) {
    
$element trim($element);
    
$pieces explode("|"$element);
    echo 
$pieces[2] . "<BR/>" "<b>Posted by " $pieces[1] . " on " $pieces[0] . "</b>\n";
    echo 
"&nbsp;<a href=\"$PHP_SELF?action=delete&id=$key\">Delete</a>\n";
    echo 
"&nbsp;<a href=\"$PHP_SELF?action=edit&id=$key\">Edit</a>\n";
    echo 
"<BR/><BR/>\n";
}
echo 
"<HR/>\n";
echo 
"<H1><u>Add News</u></H1>\n";
if(
$HTTP_POST_VARS['submit']) {
    if(
$HTTP_POST_VARS['password'] == 'test') {
        if(!
$HTTP_POST_VARS['name']) {
            echo 
"You must enter a name";
            exit;
        }
        if(!
$HTTP_POST_VARS['news']) {
            echo 
"You must enter some news";
            exit;
        }
        if(
strstr($HTTP_POST_VARS['name'],"|")) {
            echo 
"Name cannot contain the pipe symbol - |";
            exit;
        }
        if(
strstr($HTTP_POST_VARS['news'],"|")) {
            echo 
"News cannot contain the pipe symbol - |";
            exit;
        }
        
$fp fopen('news.txt','a');
        if(!
$fp) {
            echo 
"Error opening file!";
            exit;
        }
        
$line date("m.d.y") . "|" $HTTP_POST_VARS['name'];
        
$line .= "|" $HTTP_POST_VARS['news'];
        
$line str_replace("\r\n","<BR/>",$line);
        
$line .= "\r\n";
        
fwrite($fp$line);
        if(!
fclose($fp)) {
            echo 
"Error closing file!";
            exit;
        }
        echo 
"<b>News added!</b>\n";    
    } else {
        echo 
"Bad Password";
    }
}

?>
<FORM ACTION="<?=$PHP_SELF?>" METHOD="POST" NAME="newsentry">
Your name:<BR/>
<INPUT TYPE="text" SIZE="30" NAME="name"><BR/>
The News:<BR/>
<TEXTAREA NAME="news" COLS="40" ROWS="5"></TEXTAREA><BR/><BR/>
News Password:<BR/>
<INPUT TYPE="password" SIZE="30" NAME="password"><BR/>
<INPUT TYPE="submit" NAME="submit" VALUE="Post it!"><BR/>
</FORM>