City jQuery AJAX Autocomplete


  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.     <title>Demo -country state city dropdown using jquery ajax</title>
  5.     <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
  6.     <link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
  7.     <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.js"></script>
  8.     <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/bootstrap-3-typeahead/4.0.2/bootstrap3-typeahead.js"></script>
  9. </head>
  10. <style>
  11. .cen{
  12.     width:50%;
  13.     margin: 0 auto;
  14. }
  15. @media (max-width: 400px) { 
  16.     .cen{
  17.         width: 80%;
  18.         margin: 0 auto;
  19.     }
  20. }
  21. </style>
  22. <body>
  23.     <div class="row">
  24.         <div class="cen">
  25.         <h3></h3>Demo : Country state city dropdown using jquery ajax</h3>
  26. if(isset($_POST['city']) && isset($_POST['date']) && isset($_POST['time'])){
  27. echo '<h3>Output</h3><hr><dl class="dl-horizontal">';
  28. echo "<dt>Country</dt>  <dd>". $_POST['country'] ."</dd>";
  29. echo "<dt>State</dt>    <dd>". $_POST['state'] ."</dd>";
  30. echo "<dt>City</dt>     <dd>". $_POST['city'] ."</dd>";    
  31. echo "<dt>Date</dt>     <dd>". $_POST['date'] ."</dd>";
  32. echo "<dt>Time</dt>     <dd>". $_POST['time'] ."</dd><dl><hr>";
  33. }    
  34.             <form action="city-search.php"  method="post">
  35.             <div class="row">
  36.                     <div class="form-group col-sm-6">
  37.                         <label for="a">Date</label>
  38.                         <input type="date" name="date" id="date"  class="form-control"/>
  39.                     </div>
  40.                     <div class="form-group col-sm-6">
  41.                         <label for="a">Time</label>
  42.                         <input type="time" name="time" id="time"  class="form-control"/>
  43.                     </div>
  44.             </div>        
  45.                 <div class="form-group">
  46.                     <label for="a">Search City:</label>
  47.                     <input type="text" name="city" id="city" autocomplete="off" class="form-control typeahead"/>
  48.                 </div>
  49.                 <div class="row">
  50.                     <div class="form-group col-sm-4">
  51.                         <label for="a">Country</label>
  52.                         <input type="text" name="country" id="country" readonly class="form-control"/>
  53.                     </div>
  54.                     <div class="form-group col-sm-4">
  55.                         <label for="a">State</label>
  56.                         <input type="text" name="state" id="state" readonly class="form-control"/>
  57.                     </div>
  58.                     
  59.                     <div class="form-group col-sm-4">
  60.                         <label for="a">Country Code</label>
  61.                         <input type="text" name="country_code" id="country_code" readonly class="form-control"/>
  62.                     </div>
  63.                 </div>
  64.                 <div class="form-group ">
  65.                         <input type="submit" name="submit" id="submit" value="Submit" class="form-control"/>
  66.                 </div>
  67.             </form>
  68.         </div>
  69.         
  70.     </div>
  71. </body>
  72. <script>
  73.     $(document).ready(function () {
  74.         $('#city').typeahead({
  75.             source: function (query, result) {
  76.             states = [];
  77.             map = {};
  78.                 $.ajax({
  79.                     url: "http://astrologyclass.org/api/server.html?q=" + query,
  80.                     minLength: 2,           
  81.                     dataType: "json",
  82.                     type: "GET",
  83.                     success: function (data) {
  84.                         $.each(data, function (i, state) {
  85.                         map[state.city_name] = state;
  86.                         states.push(state.city_name);
  87.                         });
  88.                         result(states);
  89.                     }
  90.                 });
  91.             },
  92.             afterSelect: function(item) {
  93.             
  94.             $("#country").val(map[item].country_name);
  95.             $("#state").val(map[item].state_name);
  96.             $("#country_code").val(map[item].country_code);
  97.             }            
  98.         });
  99.     });
  100.     
  101. </script>
  102. </html>

Demo

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);
}

Ajax validate and display forms with Bootstrap

Simple & easy, This class can compose, ajax validate and display forms with Bootstrap. It can compose and display forms with common fields using Bootstrap to render the forms using a given template in HTML. The class can also validate the submitted form values according to given validation rules.

Download Zip File   Demo

Count user visits and display in a image widget

This class count user visits and display in a image widget. It can record the accesses of site visitors in a MySQL database. The class can also generate an image for a widget that displays the number of visitors of the site pages. The image widget details like font color, font style, font, background color can be configured.

Download    Demo