Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $cat = mysqli_query($link,
- "SELECT DISTINCT `category` FROM `news` ORDER BY `category` ASC"
- );
- while($row = mysqli_fetch_assoc($cat)){?>
- <a href="#">
- <?php if(mysqli_num_rows($cat) <= 5){
- echo htmlspecialchars($row['category']);
- } else {
- <a href="#">all</a>
- }
- ?>
- </a>
- $cat = mysqli_query($link,
- "SELECT DISTINCT `category` FROM `news` ORDER BY `category` LIMIT 6"
- );
- $idx = 0;
- while($row = mysqli_fetch_assoc($cat)) {
- $idx++;
- echo '<a href="#">';
- // если вывели меньше пяти строк или нет шестой
- if ($idx < 5 || !mysqli_fetch_assoc($cat))
- echo htmlspecialchars($row['category']);
- else
- echo "all";
- echo '</a>';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement