this will probably be a double-posting...
Staffan,
The client for this project has the ability to change the text for a given page/topic, through a form. The data for a 'page/topic' is kept in a single database column field, with a key to retreive it for the correct page. The amount of text could be one sentence, a half page, a full page, or anything up to two pages. So, without knowing the amount of text expected to appear on the page, I figured it would be better to dynamically generate a second page, if necessary.
Vincent,
In my understanding of PHP as a server-side language engine, the server does all the work and since the interpreter is very fast, I doubt you will notice much lag-time for generating the second page...it is strictly text, no graphics. As far as url length, or more importantly the max length for a form post method, I have sent some pretty lengthy post data for form processing in the past, and have yet to run into a length issue. I think I remember seeing something about the differences between 'get' and 'post', and one of them is length (post being larger I think). Anyway, after thinking some more about my last example code, I've come up with an alternative that does not pass the entire text string in the url:
// set max page length in characters...
$max = 500;
$newstart = $max + 1;
// text is pulled from the database and stored in '$text' (I won't do that here...)
// then we get the length of the text...
$length = strlen($text);
if ($length > $max) {
$text_page1 = substr($text, 0, $max);
print($text_page1);
// create link with a flag set that there IS a second page, and send record#
print("<A HREF=\"page.php?nextpage=1&record=" . $number . \">more</A>");
} else {
echo $text;
}
...(put the following at top of page, so that we check for it first):
if ($nextpage == "1") {
// get record from database using $record as ID (as defined in the link)...
// then extract everything from $max+1 to end of data...
$moretext = substr($text, $newstart, $length);
echo $moretext;
}
other than doing a little logic to make sure we don't reprint the first page again, this should work a bit slicker, and NOT pass a lot of text through the url...
better?
-jimm