12-22-2011, 09:49 AM
|
#41 (permalink)
|
|
The Visitor
Join Date: Dec 2011
Posts: 2
Thanks: 0
|
<?php
$newp = $_GET['p'];
$plimit = "3";
include_once 'connect_db.php';
$strSQL = mysql_query("SELECT * FROM messages");
$totalrows = mysql_num_rows($strSQL);
$pnums = ceil ($totalrows/$plimit);
if ($newp==''){ $newp='1'; }
$start = ($newp-1) * $plimit;
$starting_no = $start + 1;
if ($totalrows - $start < $plimit) { $end_count = $totalrows;
} elseif ($totalrows - $start >= $plimit) { $end_count = $start + $plimit; }
?>
<div>viewing <?php print_r("$starting_no");?> - <?php print_r("$end_count");?> of <?php print_r("$totalrows");?> entries</div>
<?php
if ($totalrows - $end_count > $plimit) { $var2 = $plimit;
} elseif ($totalrows - $end_count <= $plimit) { $var2 = $totalrows - $end_count; }
?>
<table>
<tr>
<td id="pages">pages: </td>
<?php if ($newp>1) { ?>
<td> <a href="<?php echo "pagination4.php/page.php?p=".($newp-1);?>">«</a></td>
<?php } for ($i=1; $i<=$pnums; $i++) { if ($i!=$newp){ ?>
<td><a href="<?php echo "pagination4.php/page.php?p=$i";?>"><?php print_r("$i");?></a></td>
<?php } else { ?>
<td id="current"><?php print_r("$i");?></td>
<?php }} if ($newp<$pnums) { ?>
<td><a href="<?php echo "pagination4.php/page.php?p=".($newp+1);?>">»</a></td>
<?php } ?>
</tr></table>
<ul>
<?php
include_once 'connect_db.php';
$SQL = mysql_query("SELECT msg_id,message FROM messages LIMIT $start,$plimit");
while ($row = mysql_fetch_array($SQL)) {
$field1 = $row["msg_id"];
$field2 = $row["message"];
?>
<li> <?=$field1?> and <?=$field2?> </li>
<?php
}//END SQL
?>
</ul>
|
|
|
|