Jump to content

Giovanni

New Members
  • Posts

    2
  • Joined

  • Last visited

Giovanni's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. wow, I will get into it and will use your rewrite.. I will read more and more to improve my code, as I said I am learning and learning. Thank you very much..
  2. Hello, I am a newbie regarding php, I created a website with a MySql database, I have added pagination. Everything is workign fine. One function I dont get working properly. I want to have the max of pages between the <<prev and the next>> button limited to 10, So like google.. <<prev 1,2,3,4,5,6,7,8,9,10 next>> now its like <<prev 1,2,3,4,5,6,7,8,9,10,11,12,13,14 next>> etc etc. Ill hope someone can help me out. <?php require_once('./include/connect.php'); $page = $_REQUEST["page"]; $amount = 10; $start = $page * $amount; $currentpage = $page + 1; $queryamount = $amount + 1; $query = "SELECT date, id1, id2, id3, id4, id5, id6, id7 FROM member LIMIT $start, $queryamount"; $response = mysqli_query($link, $query); $query2 = "SELECT COUNT(*) as total FROM wotd_id"; $response2 = mysqli_query($link, $query2); $row2 = mysqli_fetch_assoc($response2); $totalpages = ceil($row2['total'] / $amount); if($response){ echo "<center>(You are on Page <b>$currentpage</b> of <b>$totalpages </b>) </center>"; $result = mysqli_query ($link,"select count(1) FROM member"); if($result) { $row = mysqli_fetch_array($result); $total = $row[0]; echo "<center>Currently there are <b>$total</b> entry's in the Database </center>"; } $i = $amount; while($row = mysqli_fetch_array($response)){ $i--; if($i < 0) break; } if($page > 0) { echo "<a href= '" . $_SERVER["PHP_SELF"] . "?page=" . ($page-1) . "' class='button'><b> << Prev</b></a>&nbsp"; } for($i = 1; $i <= $totalpages; $i++) { //echo "<a href= '" . $_SERVER['PHP_SELF'] . "?page=" . ($i-1) . "'>"; if($i == $currentpage) { echo "<span class=active_page>[" . $i . "]</span>"; } else { //echo "<span class = page_nonactive>" $i "</span>"; echo "<a href= '" . $_SERVER['PHP_SELF'] . "?page=" . ($i-1) . "'>"; echo "<span class=nonactive>" .$i . "</span>"; } echo "</a> "; } for($i = $currentpage + 1; $i <= min($currentpage + 11, $total_pages); $i++) if($currentpage < $totalpages) { echo "<a href='" . $_SERVER["PHP_SELF"] . "?page=" . ($page+1) . "' class='button'><b>Next >> </b></a>&nbsp"; } } else { echo "Couldn't issue database query"; echo mysqli_error($link); } mysqli_close($link); ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.