Здравствуйте! Помогите разобраться. Создаю постраничную навигацию вида 123456...9, но не получается сделать точки вместо страниц сам код //$total общее кол-во страниц определяется автоматически if ($page+5 < $total) { $strtotal = '<li><p class="nav_point">...</p></li><li><a href="index.php?page='.$total.'">'.$total.'</a></li>'; }else { $strtotal = ""; } От чего это может зависеть? Как решить проблему
точки вместо названия ссылки? Добавлено спустя 8 минут 7 секунд: если надо выводит список, то убрать оттуда ссылку Код (Text): $strtotal = '<li><p class="nav_point">...</p></li><li>'.$total.'</li>';
Нужно чтобы расчитывалось количество страниц по заданному количеству товаров на одной странице Затем создавалась постраничная навигация таким образом, чтобы: пример. < 1 2 3 4 5 . . .12 > а не < 1 2 3 4 5 6 7 8 9 10 11 12 > то есть чтобы часть номеров скрывалась точками $num = 1; // Сколько хотим выводить товаров. $page = (int)$_GET['page']; $count = mysql_query("SELECT COUNT(*) FROM table_products WHERE visible = '1'",$link); $temp = mysql_fetch_array($count); if ($temp[0] > 0) { $tempcount = $temp[0]; //находим общее число страниц $total = (($tempcount - 1) / $num) + 1; $total = intval($total); $page = intval($page); if(empty($page) or $page < 0) $page = 1; if($page > $total) $page = $total; //Вычисляем с какого номера выводить товары $start = $page * $num - $num; $qury_start_num = " LIMIT $start, $num"; } $result = mysql_query("SELECT * FROM table_products WHERE visible= '1' ORDER BY $sorting $qury_start_num",$link); If (mysql_num_rows($result) > 0) { $row = mysql_fetch_array($result); do { if ($row["images"] != "" && file_exists("./uploads_images/".$row["images"])) { $img_path = './uploads_images/'.$row["images"]; $max_width = 200; $max_height = 200; list($width, $height) = getimagesize($img_path); $ratioh = $max_height/$height; $ratiow = $max_width/$width; $ratio = min($ratioh, $ratiow); $width = intval($ratio*$width); $height = intval($ratio*$height); }else { $img_path = "/images/no_image.png"; $width = 110; $height = 200; } echo ' <li> <div class="block_images_grid"> <img src="'.$img_path.'" width="'.$width.'" height="'.$height.'" /> </div> <p class="style_title_grid" ><a href="" >'.$row["title"].'</a></p> <ul class="reviews_and_counts_grid"> <li><img src="/images/eye_icon.png" /><p>0</p></li> <li><img src="/images/comment_icon.png" /><p>0</p></li> </ul> <a class="add_cart_style_grid" ></a> <p class="style_price_grid"><strong>'.$row["price"].'</strong> руб.</p> <div class="mini_features" > '.$row["mini_features"].' </div> </li> '; } while ($row = mysql_fetch_array($result)); } ?> </ul> <ul id="block_tovar_list"> <?php $result = mysql_query("SELECT * FROM table_products WHERE visible='1' ORDER BY $sorting $qury_start_num",$link); If (mysql_num_rows($result) > 0) { $row = mysql_fetch_array($result); do { if ($row["images"] != "" && file_exists("./uploads_images/".$row["images"])) { $img_path = './uploads_images/'.$row["images"]; $max_width = 150; $max_height = 150; list($width, $height) = getimagesize($img_path); $ratioh = $max_height/$height; $ratiow = $max_width/$width; $ratio = min($ratioh, $ratiow); $width = intval($ratio*$width); $height = intval($ratio*$height); }else { $img_path = "/images/noimages80x70.png"; $width = 80; $height = 70; } echo ' <li> <div class="block_images_list"> <img src="'.$img_path.'" width="'.$width.'" height="'.$height.'" /> </div> <ul class="reviews_and_counts_list"> <li><img src="/images/eye_icon.png" /><p>0</p></li> <li><img src="/images/comment_icon.png" /><p>0</p></li> </ul> <p class="style_title_list" ><a href="" >'.$row["title"].'</a></p> <a class="add_cart_style_list" ></a> <p class="style_price_list"><strong>'.$row["price"].'</strong> руб.</p> <div class="style_text_list" > '.$row["mini_description"].' </div> </li> '; } while ($row = mysql_fetch_array($result)); } echo '</ul>'; if ($page != 1){ $pstr_prev = '<li><a class="pstr_prev" href="index.php?page='.($page - 1).'"><</a></li>';} if ($page != $total) $pstr_next = '<li><a class="pstr_next" href="index.php?page='.($page + 1).'">></a></li>'; // Формируем ссылки со страницами if($page - 5 > 0) $page5left = '<li><a href="index.php?page='.($page - 5).'">'.($page - 5).'</a></li>'; if($page - 4 > 0) $page4left = '<li><a href="index.php?page='.($page - 4).'">'.($page - 4).'</a></li>'; if($page - 3 > 0) $page3left = '<li><a href="index.php?page='.($page - 3).'">'.($page - 3).'</a></li>'; if($page - 2 > 0) $page2left = '<li><a href="index.php?page='.($page - 2).'">'.($page - 2).'</a></li>'; if($page - 1 > 0) $page1left = '<li><a href="index.php?page='.($page - 1).'">'.($page - 1).'</a></li>'; if($page + 5 <= $total) $page5right = '<li><a href="index.php?page='.($page + 5).'">'.($page + 5).'</a></li>'; if($page + 4 <= $total) $page4right = '<li><a href="index.php?page='.($page + 4).'">'.($page + 4).'</a></li>'; if($page + 3 <= $total) $page3right = '<li><a href="index.php?page='.($page + 3).'">'.($page + 3).'</a></li>'; if($page + 2 <= $total) $page2right = '<li><a href="index.php?page='.($page + 2).'">'.($page + 2).'</a></li>'; if($page + 1 <= $total) $page1right = '<li><a href="index.php?page='.($page + 1).'">'.($page + 1).'</a></li>'; if ($page+5 < $total) { $strtotal = '<li><p class="nav_point">...</p></li><li><a href="index.php?page='.$total.'">'.$total.'</a></li>'; //<li><a href="index.php?page='.$total.'">'.$total.'</a></li> }else { $strtotal = ""; } if ($total > 1) { echo ' <div class="pstrnav"> <ul> '; echo $pstr_prev.$page5left.$page4left.$page3left.$page2left.$page1left."<li><a class='pstr_active' href='index.php?page=".$page."'>".$page."</a></li>".$page1right.$page2right.$page3right.$page4right.$page5right.$pstr_next; echo ' </ul> </div> '; }