Bootstrap Pager


  1. <?
  2. $total_query=30;
  3. $active_page_number=1;
  4. $per_page_display=10;
  5. if(isset($_GET['page-number'])){
  6.     $active_page_number ctype_digit($_GET['page-number'])? $_GET['page-number'] : 1;
  7.     echo "<h1>Page Number " $_GET['page-number'] . "</h1>";
  8.     echo "<br>Per Page Display "$per_page_display;
  9.     echo "<br>Active Page Number "$active_page_number;
  10.     echo "<br>Total Query "$total_query;
  11. }
  12. echo pager("?","page-number=",$total_query,$active_page_number,$per_page_display);
  13. function pager($q,$p="page",$totalRow=30,$currentPage=1,$perPageDisplay=10)
  14. {
  15. $pp="";
  16. $leftDisplay=4;
  17. $rightDisplay=4;
  18. $totalPage=ceil($totalRow $perPageDisplay);
  19. if($currentPage $totalPage)
  20. $currentPage=1;
  21. $lplus=0;
  22. $rplus=0;
  23. if($totalPage 10)
  24. {
  25. for($i=1;$i<=$totalPage;$i++)
  26. if($currentPage == $i)
  27. $pp .= "<li><a href=\"$q$p$i\" class=\"active\"> $i  </a></li>";
  28. else
  29. $pp .= "<li><a href=\"$q$p$i\" > $i  </a></li>";
  30. }
  31. else
  32. {
  33. if($currentPage <= $leftDisplay){
  34. $lplus=$leftDisplay $currentPage;
  35. $l=1;
  36. $rightDisplay $rightDisplay $lplus;
  37. $end="<li><a href=\"$q$p$totalPage\" aria-label=\"Next\"><span aria-hidden=\"true\">&raquo;</span></a></li>";
  38. }
  39. else{
  40. $l=$currentPage $leftDisplay;
  41. $end="<li><a href=\"$q$p$totalPage\" aria-label=\"Next\"><span aria-hidden=\"true\">&raquo;</span></a></li>";
  42. }
  43. if(($currentPage $rightDisplay) >= $totalPage){
  44. $rplus=($currentPage $rightDisplay) - $totalPage;
  45. $r=$totalPage;
  46. $l=$l-$rplus;
  47. $start="<li><a href=\"".$q.$p."1\" aria-label=\"Previous\"><span aria-hidden=\"true\">&laquo;</span></a></li>";
  48. }
  49. else{
  50. $r=$currentPage $rightDisplay;
  51. $start="<li><a href=\"".$q.$p."1\" aria-label=\"Previous\"><span aria-hidden=\"true\">&laquo;</span></a></li>";
  52. }
  53. $pp $start;
  54. for($i=$l;$i<=$r;$i++){
  55. if($currentPage == $i)
  56.  $pp .= "<li class=\"active\"><a href=\"$q$p$i\">$i<span class=\"sr-only\">$i</span></a></li>";
  57. else
  58.  $pp .= "<li><a href=\"$q$p$i\">$i</a></li>";
  59. }
  60. $pp .= $end;
  61. }
  62. return $pp;
  63. }

php code encode decode string

Encode Decode String

example———————————

$r=base64_encode(encode(“vishv sahdev”));
echo “<br>”.$r;
$r=decode(base64_decode($r));
echo “<br>”.$r;

————————————————————-

$r=encode(“vishv sahdev”);
echo “<br>”.$r;
$r=decode($r);
echo “<br>”.$r;

——————————————————————


  1. <?
  2. function encode($r){
  3. $n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcedfghijklmnopqrstuvwxyz0123456789-";
  4. $convert 'y1xYsKjeXT7o3iHrCVz0uwLFtWcPbD4kMahdNAIJ5En-pGfOUQBq9m6v28RgZlS';
  5. $numbers1 str_split($r);
  6. $f=array_combine(str_split($n), str_split($convert));
  7. $x='';
  8. foreach($numbers1 as $k=&gt;$v)
  9. if(isset($f[$v]))
  10. $x .= $f[$v];
  11. else
  12. $x .= $v;
  13. return $x;
  14. }
  15. function decode($r){
  16. $n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcedfghijklmnopqrstuvwxyz0123456789-";
  17. $convert 'y1xYsKjeXT7o3iHrCVz0uwLFtWcPbD4kMahdNAIJ5En-pGfOUQBq9m6v28RgZlS';
  18. $numbers1 str_split($r);
  19. $f=array_combine(str_split($n), str_split($convert));
  20. $f=array_flip($f);
  21. $x='';
  22. foreach($numbers1 as $k=&gt;$v){
  23. if(isset($f[$v]))
  24. $x .= $f[$v];
  25. else
  26. $x .= $v;
  27. }
  28. return $x;
  29. }


generate password php code

Generate Password
function generate_password(){
$chars[0] = "abcdeghijklmnpqrstvwxyz"; // 4 chars
$chars[1] = "ABCDEFGHIJKLMNPQSTVWXYZ"; // 2 chars
$chars[2] = "012345789"; // 2chars
$chars[3] = "$#@!%^&*_-+"; // 2chars
$cc=[4,2,2,2];  //
for($g=0;$g<4;$g++){
for($i=0;$i<$cc[$g];$i++){
$key[]= substr($chars[$g],(rand()%(strlen($chars[$g]))), 1);
}
}
shuffle($key);
return implode("",$key);
}