Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Split the article into pages frustration

Status
Not open for further replies.

kupe

Technical User
Sep 23, 2002
376
I have two lots of code. One lists articles for display, and click on the item and that story appears. It works well.

If one of the stories is long, I want it to appear bit by bit, or page by page, using the term [PAGEBREAK].

This code works fine. But – being short of knowledge – I don’t know where to put it in the first code. My efforts so far stop both codes from working.

Be most grateful for guidance, please.

Code 1:

<?php
//display individual records
if($id) {
$result = mysql_query("SELECT * FROM maystu WHERE MayID=$id", $db);


$myrow = mysql_fetch_array($result);


printf("<h4>%s\n</h4>", $myrow["Headline"]);
printf(" %s\n<br>", $myrow["NewsStory"]);
//from laura teeple tecktips 11/5/05
if ($myrow["Byline"])
printf("<div class=\"names2\">- %s</div>",
$myrow["Byline"]);

//printf("<div class=\"names2\">- %s</div>", $myrow["Byline"]);
printf("Bulletin: %s",
date("F d", strtotime($myrow["NewsDate"])));

} else {
//show archives list
$result = mysql_query("SELECT * FROM maystu ORDER BY NewsDate DESC", $db);

if ($myrow = mysql_fetch_array($result)) {

//display list if there are records to display


do {
//line below for formatting the teaser text
printf("<a href=\"%s?id=%s\">
<font size=\"3\">%s</font></a><br>
%s\n<br> <font color=\"#999999\">
%s</font><p></p>\n",

$PHP_SELF,$myrow["JanID"],
$myrow["Headline"],
$myrow["Blurb"],
date("F d", strtotime($myrow["NewsDate"]))); //To return Year just add Y beside "M d Y",

} while ($myrow = mysql_fetch_array($result));

} else {
echo "Sorry, nuttin' found";
}
}


Code 2:
//======== p a g e b r e a k s
$NewsStory = $joke['NewsStory'];
// If no page requested, default to the first page ($page = 0)
if (!isset($_GET['page'])) {
$page = 0;
} else {
$page = $_GET['page'];
}

// divide text into an array of pages
$textarray = spliti('\[PAGEBREAK]', $NewsStory);

// Select the wanted page
$joketext = $textarray[$page];

$PHP_SELF = $_SERVER['PHP_SELF'];

if ($page != 0) {
$prevpage = $page - 1;
echo "<p><a href=\"$PHP_SELF?id=$id&amp;page=$prevpage\">".
'Previous Page</a></p>';
}

echo "<p>$joketext</p>";

if ($page < count($textarray) - 1) {
$nextpage = $page + 1;
echo "<p><a href=\"$PHP_SELF?id=$id&amp;page=$nextpage\">".
'Next Page</a></p>';
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top