This may help.
This implies that the lowest id in the db is the newest.
Just write the code to get the poem from the db by id and the code to show it (possibly on the next page).
Then call poem(); and it will do the work.
It will return false if the poem it got a bad number from strlen(); or if the poem is empty.
It will return 3 if it showed two poems, or 4 if it showed one and continued.
I hope this helps you!
<?php
function getpoem($id=1)
{
//Code to get poem and return it
}
function showpoem($poem,$continueonnextpage=false)
{
//Code to show poem (and possibly continue on next page)
}
function poem($id=1)
{
$length1 = strlen(getpoem($id));
if ($length<=20&&$length!==0)
{
showpoem(getpoem());
showpoem(getpoem(2));
return 3;
}
elseif ($length>20)
{
showpoem(getpoem(),true);
return 4;
}
else
{
return false;
}
?>