I have a problem is that the main URL i.e saadi.000a.biz starts from page number 2. What I mean to say is that the default website address of mine displays page number 2 as its default page. I want to show page number 1 as my default page as I am showing my database result in chronological order. Please help. The coding is as follow: <?php include("mysql_connect.php"); mysql_select_db("a000b_5538273_blog_posts", $con_mysql_db); if (isset($_GET['pageno'])) { $pageno = $_GET['pageno']; } else { $pageno = 5; } // if $query = "SELECT count(*) FROM posts"; $result = mysql_query($query, $con_mysql_db) or trigger_error("SQL", mysql_error); $query_data = mysql_fetch_row($result); $numrows = $query_data[0]; $rows_per_page = 5; $lastpage = ceil($numrows/$rows_per_page); $pageno = (int)$pageno; if ($pageno > $lastpage) { $pageno = $lastpage; } // if if ($pageno < 1) { $pageno = 1; } // if $limit = 'LIMIT ' .($pageno - 1) * $rows_per_page .',' .$rows_per_page; $result = mysql_query("SELECT post_title, post_body From posts ORDER BY post_no DESC $limit"); while($row = mysql_fetch_array($result)) { $title = $row[0]; $content = $row[1]; echo("<h3>" .$title ."</h3><hr style='color: brown'><br/> .$content" ."<hr style='width: 80%; align: center; color: brown'><br/><br/><br/>"); }; $result = mysql_query($query, $con_mysql_db) or trigger_error("SQL", E_USER_ERROR); /* ... process contents of $result ... */ if ($pageno == 1) { echo " FIRST PREV "; } else { echo " <a href='{$_SERVER['PHP_SELF']}?pageno=1'>FIRST</a> "; $prevpage = $pageno - 1; echo " <a href='{$_SERVER['PHP_SELF']}?pageno=$prevpage'>PREV</a> "; } // if echo " ( Page $pageno of $lastpage ) "; if ($pageno == $lastpage) echo " NEXT LAST "; else { $nextpage = $pageno+1; echo " <a href='{$_SERVER['PHP_SELF']}?pageno=$nextpage'>NEXT</a> "; echo " <a href='{$_SERVER['PHP_SELF']}?pageno=$lastpage'>LAST</a> "; } // if ?> PHP:
hmmm... try this: if (isset($_GET['pageno'])) { $pageno = $_GET['pageno']; } else { $pageno = 1; } instead of: if (isset($_GET['pageno'])) { $pageno = $_GET['pageno']; } else { $pageno = 5; } but still not sure if it will work
lol, great i was lazy and didn;t read ur whole post just few coding lines. anyways i am happy that i helped