<!DOCTYPE html>- <html>
- <head>
- <title>Demo -country state city dropdown using jquery ajax</title>
- <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
- <link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
- <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.js"></script>
- <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/bootstrap-3-typeahead/4.0.2/bootstrap3-typeahead.js"></script>
- </head>
- <style>
- .cen{
- width:50%;
- margin: 0 auto;
- }
- @media (max-width: 400px) {
- .cen{
- width: 80%;
- margin: 0 auto;
- }
- }
- </style>
- <body>
- <div class="row">
- <div class="cen">
- <h3></h3>Demo : Country state city dropdown using jquery ajax</h3>
- if(isset($_POST['city']) && isset($_POST['date']) && isset($_POST['time'])){
- echo '<h3>Output</h3><hr><dl class="dl-horizontal">';
- echo "<dt>Country</dt> <dd>". $_POST['country'] ."</dd>";
- echo "<dt>State</dt> <dd>". $_POST['state'] ."</dd>";
- echo "<dt>City</dt> <dd>". $_POST['city'] ."</dd>";
- echo "<dt>Date</dt> <dd>". $_POST['date'] ."</dd>";
- echo "<dt>Time</dt> <dd>". $_POST['time'] ."</dd><dl><hr>";
- }
- <form action="city-search.php" method="post">
- <div class="row">
- <div class="form-group col-sm-6">
- <label for="a">Date</label>
- <input type="date" name="date" id="date" class="form-control"/>
- </div>
- <div class="form-group col-sm-6">
- <label for="a">Time</label>
- <input type="time" name="time" id="time" class="form-control"/>
- </div>
- </div>
- <div class="form-group">
- <label for="a">Search City:</label>
- <input type="text" name="city" id="city" autocomplete="off" class="form-control typeahead"/>
- </div>
- <div class="row">
- <div class="form-group col-sm-4">
- <label for="a">Country</label>
- <input type="text" name="country" id="country" readonly class="form-control"/>
- </div>
- <div class="form-group col-sm-4">
- <label for="a">State</label>
- <input type="text" name="state" id="state" readonly class="form-control"/>
- </div>
- <div class="form-group col-sm-4">
- <label for="a">Country Code</label>
- <input type="text" name="country_code" id="country_code" readonly class="form-control"/>
- </div>
- </div>
- <div class="form-group ">
- <input type="submit" name="submit" id="submit" value="Submit" class="form-control"/>
- </div>
- </form>
- </div>
- </div>
- </body>
- <script>
- $(document).ready(function () {
- $('#city').typeahead({
- source: function (query, result) {
- states = [];
- map = {};
- $.ajax({
- url: "http://astrologyclass.org/api/server.html?q=" + query,
- minLength: 2,
- dataType: "json",
- type: "GET",
- success: function (data) {
- $.each(data, function (i, state) {
- map[state.city_name] = state;
- states.push(state.city_name);
- });
- result(states);
- }
- });
- },
- afterSelect: function(item) {
- $("#country").val(map[item].country_name);
- $("#state").val(map[item].state_name);
- $("#country_code").val(map[item].country_code);
- }
- });
- });
- </script>
- </html>
Author: vishvsahdev
Bootstrap Pager
<?- $total_query=30;
- $active_page_number=1;
- $per_page_display=10;
- if(isset($_GET['page-number'])){
- $active_page_number = ctype_digit($_GET['page-number'])? $_GET['page-number'] : 1;
- echo "<h1>Page Number " . $_GET['page-number'] . "</h1>";
- echo "<br>Per Page Display ". $per_page_display;
- echo "<br>Active Page Number ". $active_page_number;
- echo "<br>Total Query ". $total_query;
- }
- echo pager("?","page-number=",$total_query,$active_page_number,$per_page_display);
- function pager($q,$p="page",$totalRow=30,$currentPage=1,$perPageDisplay=10)
- {
- $pp="";
- $leftDisplay=4;
- $rightDisplay=4;
- $totalPage=ceil($totalRow / $perPageDisplay);
- if($currentPage > $totalPage)
- $currentPage=1;
- $lplus=0;
- $rplus=0;
- if($totalPage < 10)
- {
- for($i=1;$i<=$totalPage;$i++)
- if($currentPage == $i)
- $pp .= "<li><a href=\"$q$p$i\" class=\"active\"> $i </a></li>";
- else
- $pp .= "<li><a href=\"$q$p$i\" > $i </a></li>";
- }
- else
- {
- if($currentPage <= $leftDisplay){
- $lplus=$leftDisplay - $currentPage;
- $l=1;
- $rightDisplay = $rightDisplay + $lplus;
- $end="<li><a href=\"$q$p$totalPage\" aria-label=\"Next\"><span aria-hidden=\"true\">»</span></a></li>";
- }
- else{
- $l=$currentPage - $leftDisplay;
- $end="<li><a href=\"$q$p$totalPage\" aria-label=\"Next\"><span aria-hidden=\"true\">»</span></a></li>";
- }
- if(($currentPage + $rightDisplay) >= $totalPage){
- $rplus=($currentPage + $rightDisplay) - $totalPage;
- $r=$totalPage;
- $l=$l-$rplus;
- $start="<li><a href=\"".$q.$p."1\" aria-label=\"Previous\"><span aria-hidden=\"true\">«</span></a></li>";
- }
- else{
- $r=$currentPage + $rightDisplay;
- $start="<li><a href=\"".$q.$p."1\" aria-label=\"Previous\"><span aria-hidden=\"true\">«</span></a></li>";
- }
- $pp = $start;
- for($i=$l;$i<=$r;$i++){
- if($currentPage == $i)
- $pp .= "<li class=\"active\"><a href=\"$q$p$i\">$i<span class=\"sr-only\">$i</span></a></li>";
- else
- $pp .= "<li><a href=\"$q$p$i\">$i</a></li>";
- }
- $pp .= $end;
- }
- return $pp;
- }
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;
——————————————————————
<?- function encode($r){
- $n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcedfghijklmnopqrstuvwxyz0123456789-";
- $convert = 'y1xYsKjeXT7o3iHrCVz0uwLFtWcPbD4kMahdNAIJ5En-pGfOUQBq9m6v28RgZlS';
- $numbers1 = str_split($r);
- $f=array_combine(str_split($n), str_split($convert));
- $x='';
- foreach($numbers1 as $k=>$v)
- if(isset($f[$v]))
- $x .= $f[$v];
- else
- $x .= $v;
- return $x;
- }
- function decode($r){
- $n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcedfghijklmnopqrstuvwxyz0123456789-";
- $convert = 'y1xYsKjeXT7o3iHrCVz0uwLFtWcPbD4kMahdNAIJ5En-pGfOUQBq9m6v28RgZlS';
- $numbers1 = str_split($r);
- $f=array_combine(str_split($n), str_split($convert));
- $f=array_flip($f);
- $x='';
- foreach($numbers1 as $k=>$v){
- if(isset($f[$v]))
- $x .= $f[$v];
- else
- $x .= $v;
- }
- return $x;
- }
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);
}
Current Planetary Positions
A simple PHP Framework
Add, List, Edit and Delete
Comments php class with replies and like buttons
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.
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.