<?php
include ('config.php');
$chislo = 5;
$result = mysql_query("SELECT * from db ORDER by id desc");
$num_rows = mysql_num_rows($result);
$num_rows = round($num_rows/$chislo);
if (isset($_GET['str'])) {
$nav = $_GET['str'];
else {
$nav = 0;
}
$nav = intval($nav);
echo 'Навигация: ';
for ($i=1; $i<$num_rows; $i++) {
if ($i != $nav) {
echo '<a href="'.$PHP_SELF.'?str='.$i.'">'.$i.'</a> ';
}
else {
echo '<span>'.$i.'</span> ';
}
}
echo '<hr />';
if (!isset($_GET['str'])) {
$str = 0;
}
else {
$str = $_GET['str']*$chislo - $chislo;
}
$nomer = $str + 5;
/
$result = mysql_query("SELECT * from db ORDER by id asc limit $str, $nomer");
if (!$result) {
echo $text_error;
exit;
}
echo '<div style="width: 40%;">';
while ($row = mysql_fetch_array($result)) {
echo '<p>'.$row['id'].' - <strong>'.$row['name'].'</strong>
<br />
'.substr($row['text'],0,100).'.. <a href="text.php?nomer='.$row['id'].'">>></a></p>';
}
echo '</div>';
?>