note 20662 deleted from language.control-structures by aidan
| From: | aidan@php.net | Date: | Thu, 07 Oct 2004 13:51:23 +0000 |
| Subject: | note 20662 deleted from language.control-structures by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-78129@lists.php.net to get a copy of this message | ||
Note Submitter: maurizio at zilli dot com
----
You can also use this if/else condition structure
to control an index navigation page statement
and extract partial rows from an array.
// Init to control pointer into the array
$setlimit = 10; // rows limit
$pointer = 0; // this is the start pointer value
$next = $pointer + $setlimit; // increment the pointer
$prev= $next - $setlimit; // decrement the pointer
$total_rows = mysql_num_rows($myrows); // total rows
// You're at the beginning
if (($pointer == 0) && ($total_rows > $setlimit)):
echo"$next >>";
// You're in the middle
elseif ($next < $total_rows):
echo"<< $prev";
echo"$pointer";
echo"$next >>";
// You're in a selection with only one row
elseif (($next == $total_rows) && ($next > $total_rows)):
// You're at the end
else:
echo"<< $prev";
endif;