php - How to redirect to the page that I submit in the form (pagination) -
hello have form:
<form method="get"> <input type="number" name="page=home&paginh"> <input type="submit"> </form>
and have pagination in code...so want put field in site form above, when user write number in field , submit it, must redirect him page user wrote. problem this... result take in url http://example.com/index.php?page%3dhome%26paginh=2 number '2' in end number user submit. problem url changes page stills same. have searched lot not find solution. in advance!
yes sorry!
this php:
<?php $per_page = 1; //ayto einai apotelesma p 8a vgalei sto index(arxiko h home) ola ta post mazi. $pages_query = mysql_query("select count(`id`) `posts`") or die(mysql_error()); $pages = ceil(mysql_result($pages_query, 0) / $per_page); //$page = (isset($_get['page'])) ? (int)$_get['page'] : 1; if (isset($_get['paginh'])) { $page = (int)$_get['paginh']; } else { $page = 1; } $start = ($page - 1) * $per_page; $query = mysql_query("select * `posts` order `date` desc limit $start, $per_page") or die(mysql_error()); if(mysql_num_rows($query) == 0) { echo "<tr><td colspan=\"3\">no posts found</td></tr>"; } else { while($post = mysql_fetch_array($query)) { $article_id=$post["id"]; $link = "admin_login_bg/includes/article_result_readmore_img.php"; $var = "article_id"; $id = $post['id']; $date = $post['date']; $image = $post['image_home']; echo "<div class='perigrama'><div class='titlos'><h2><a href='admin_login_bg/includes/article_result_readmore_img.php?article_id=" . $article_id . "'><span>" . $post['title'] . "</span></a></h2></div><div class='infos'><p>posted <a href='#'><span>" . $post['author'] . "</span></a> on ". $date . " | <a href='admin_login_bg/includes/article_result_readmore_img.php?article_id=" . $article_id . "'><span>full article</span></a></p></div><tr><td><div class='image'><img src='". $image ."' width='540' height='300'></div></td></tr><div class='content'><p>" . truncate($post['content'],$link,$var,$id) . "</p></div><div class='more'><p><a href='admin_login_bg/includes/article_result_readmore_img.php?article_id=" . $article_id . "'><span>read more</span></a></p></div></div>"; } } echo '<div class="pagination"><ul><li>'; //$first = 1; //if ($pages >= 1) { // echo '<a href="?page=home&paginh='.$first.'">first</a> '; //} $prev = ($page - 1); if ($page > 1) { echo '<a class="prevnext paginh" href="?page=home&paginh='.$prev.'"><span class="velakiaprevnext"><<</span> previous</a> '; } $first = 1; if ($page > 3) { if ($pages >= 1) { echo '<a href="?page=home&paginh='.$first.'">1</a> '; } } if ($page > 3) { echo ' <span>...</span> '; } if ($pages >= 1 && $page <= $pages) { //for ($x=1; $x<=$pages; $x++) { //for ($x = $page + 0; $x <= min($page + 3, $pages); $x++) { for($x = max(1, $page - 2); $x <= min($page + 2, $pages); $x++) { //for ($x = $page + 0; $x <= max($page + 3, $pages); $x++) { echo ($x == $page) ? '<strong><a class="currentpage" href="?page=home&paginh='.$x.'">'.$x.'</a></strong> ' : '<a href="?page=home&paginh='.$x.'">'.$x.'</a> '; //} } } $p = ($pages - 3); if ($page <= $p) { echo ' <span>...</span> '; } $last = $pages; if ($page <= $p) { if ($pages >= 1) { echo '<a href="?page=home&paginh='.$last.'">'.$pages.'</a> '; } } $next = ($page + 1); if ($page < $pages) { echo '<a class="prevnext" href="?page=home&paginh='.$next.'">next <span class="velakiaprevnext">>></span></a> '; } //if ($pages >= 1) { // echo '<a href="?page=home&paginh='.$last.'">last</a> '; //} echo '</li></ul></div>'; ?>
according code , after analysis code. suggest change form code following:
<form method="get"> <input type="hidden" name="page" value="home"> <input type="number" name="paginh" value=""> <input type="submit"> </form>
this work sure.
Comments
Post a Comment