johnseito Posted February 4, 2008 Share Posted February 4, 2008 Hello everyone, I created a entry form with html and php and the data that was enter is saved into mysql. I would like to know that after a certain amount of entry it will be too much for one page to view it in the browse once it comes out. So I would like to create a button on the bottom back and forth that when click can scroll through the previous/present data that was entered. either a scroll or a click that when click then go to previous page/present page, etc. Does any have a clue how to do this? Quote Link to comment Share on other sites More sharing options...
Stooney Posted February 4, 2008 Share Posted February 4, 2008 Google search 'Pagination' Quote Link to comment Share on other sites More sharing options...
priti Posted February 4, 2008 Share Posted February 4, 2008 Hi, You will get a pagination class on PHP classes .In pagination you won't get the scroll you would be creating links for previous,next or 1,2,... maximum page no. for example refer to this url for pagination implementation. http://php.about.com/od/phpwithmysql/ss/php_pagination.htm Regards Quote Link to comment Share on other sites More sharing options...
johnseito Posted February 4, 2008 Author Share Posted February 4, 2008 thanks i'll take a look at it. Quote Link to comment Share on other sites More sharing options...
johnseito Posted February 7, 2008 Author Share Posted February 7, 2008 I wrote this code $conn =mysql_connect("localhost","TEST1","TEST"); mysql_select_db("test",$conn); if (!(isset($pagenum))) /*isset() functions for testing the status of a variable. This function takes a variable name as an argument and returns true if it exists and false otherwise. you can also pass in a comma separated list of variables, and isset() will return true if all the varaibles are set. */ { $pagenum = 1; } $data ="SELECT name, message from info"; $rows = mysql_num_rows($data, $conn); print"<font size=10000>$rows</font>"; //$rows=mysql_query($data, $conn); $page_rows = 4; $last = ceil($rows/$page_rows); if ($pagenum < 1) { $pagenum = 1; } elseif ($pagenum > $last) { $pagenum = $last; } $max = 'limit ' .($pagenum - 1) * $page_rows .',' .$page_rows; $data_p = mysql_query($data, $conn) or die(mysql_error()); while ($info = mysql_fetch_array($data_p)){ echo "{$info['name']} wrote:<br>"; echo "{$info["message"]}"; } echo "<p>"; echo " --Page $pagenum of $last-- <p>"; // First we check if we are on page one. If we are then we don't need a link to the previous page or the first page so we do nothing. If we aren't then we generate links to the first page, and to the previous page. if ($pagenum == 1) { } else { echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=1'> <<-First</a> "; echo " "; $previous = $pagenum-1; echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$previous'> <-Previous</a> "; } //just a spacer echo " ---- "; //This does the same as above, only checking if we are on the last page, and then generating the Next and Last links if ($pagenum == $last) { } else { $next = $pagenum+1; echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$next'>Next -></a> "; echo " "; echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$last'>Last ->></a> "; } ?> <HTML> <HEAD> <TITLE>WEB BLOG</TITLE> </HEAD> <BODY> <H1>Add an Entry</H1> <form method="POST" action="pagination2.php"> <p> <input type="text" name="name" value= "rrrr" size=55><br> <b><small>NAME:</small></b><br></p> <b>MESSAGE:</b><br> <textarea name="message" cols="60" rows="6"></textarea> <br> <input type="submit" name="submit" value="Submit"> </form> </BODY> </HTML> it doesn't seem to work as plan. there are the -Page 0 of 0-- <<-First <-Previous ---- link to click on but that is it, I click first/previous and it does nothing, also it shows all the data output. Anyone have any ideas what is wrong here. thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.