Jump to content

pagination


nielcleo

Recommended Posts

Hi againfirst im sorry for asking plenty questions im new at php and im willing to earn knowledge on this part..anyone here can help me to make a pagination..and i have a question about how can i make secure input fields? using a real escape string it will this disable special characters right.. but i heard someone telling there's a counter part about that? anybody here can suggest me how to secure the input fields..and about the BB Code how can i work with that also..

Link to comment
Share on other sites

that's a lot of questions. Pagination isn't hard, you just need to understand some key basic programming concepts. Have you tried anything yet? It would best if you had some code. Do you know how pagination works? Have you looked anything up on your own about how it works?

Link to comment
Share on other sites

i have here code but its not functioning correctly :)

<?php  mysql_connect("your.hostaddress.com", "username", "password") or die(mysql_error());  mysql_select_db("address") or die(mysql_error());   if (!(isset($pagenum)))  {  $pagenum = 1;  }   $data = mysql_query("SELECT * FROM topsites") or die(mysql_error());  $rows = mysql_num_rows($data);   $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("SELECT * FROM topsites $max") or die(mysql_error());  while($info = mysql_fetch_array( $data_p ))  {  Print $info['Name'];  echo "<br>"; }  echo "<p>";  echo " --Page $pagenum of $last-- <p>";  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> "; }   echo " ---- "; 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> "; }  ?>   

and i dont know where to attach the content.. :)

Link to comment
Share on other sites

so lets step back. before you can write pagination code, do you understand what pagination is? Do you know how you plan on saving the offset? Do you understand about how that offset affects the content to be displayed? You should be familiar with the subject matter before writing the code for, so you actually know what you're writing and why.

Link to comment
Share on other sites

//paging script$pages=7;//show posts on per page$page=isset($_GET['page'])?$_GET['page']:1;	$f=($page*$pages)-$pages;	$j=$pages;	$limit="ORDER BY id DESC LIMIT $f , $j"; // put this limit in the end of query//end paging script

Pagging

   $total= mysql_num_rows(mysql_query ($q)); //total enteries in database   $max_entry_per_page = 7;   $max_record_in_data_file = 10000;   $self = $_SERVER['PHP_SELF'];   $jmlrec =$total;   $jml_page = ceil($jmlrec/$max_entry_per_page);   $nomrec = $page * $max_entry_per_page - $max_entry_per_page;   $no = $page*$max_entry_per_page-$max_entry_per_page;   $ccc="";         /////////start pager///////   echo"<div class=\"pagelink\">";   if ($jml_page > 1) {          if ($page != 1){ $previus=$page-1;		                        echo "<a href=\"$self?page=1$ccc\">First Page</a>		                        <a href=\"$self?page=$previus$ccc\">Previus</a> "; }								else {echo "<a class=\"active\">First Page</a>";}          if ($jml_page > 10) {               if ($page < 5) {                  $start = 1;                  $stop = 10;              } elseif ($jml_page - $page < 5) {                  $start = $jml_page - 9;                  $stop = $jml_page;              } else {                  $start = $page-4;                  $stop = $page+5;              }              if ($start != 1){ echo '... ';}              for ($p=$start; $p<=$stop; $p++) {                  if ($p == $page) echo "<font class=\"active\"><b>$p</b></font>  ";                  else echo "<a href=\"$self?page=$p$ccc\">$p</a>  ";              }              if ($stop != $jml_page) echo '... ';              echo "of <a>$jml_page</a>";          } else {              for ($p=1; $p<=$jml_page; $p++) {                  if ($p == $page) echo "<font class=\"active\"><b>$p</b></font>  ";                  else echo "<a href=\"$self?page=$p$ccc\">$p</a>  ";              }          }          if ($page != $jml_page) { $page+=1;			  echo "<a href=\"$self?page=$page$ccc\">Next</a>			        <a href=\"$self?page=$jml_page$ccc\">Last Page</a>";}          else {echo "<a class=\"active\">Last Page</a>";}      } else {echo "";}      echo'</div>';	  ///////end pager//////

Hope This will Help You

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...