Categories
Uncategorized

How to use time and date function in php with indian timezone?

Use time and date function in php with indian timezone

<?php

if(function_exists(‘date_default_timezone_set’)) {
    date_default_timezone_set(“Asia/Kolkata”);
}

// then use the date functions, not the other way around
$date = date(“d/m/Y”);
$date1 =  date(“H:i a”);

echo $date . ‘<br/>’;
echo $date1;

?>

Categories
Uncategorized

How to assign variables in php with for loop?

assign variables in php with for loop
for($i = 0; $i <= 7; $i++) {
$name
= "variable{$i}";
$$name
= "foo";
}
or
for($i = 0; $i <= 7; $i++) {
$
{"variable$i"} = "foo";
}
or
${"jassi"} .= $_POST['skip'.$daynum];
Categories
Uncategorized

How to insert time and date in database when user login on site(login tracking)?

login tracking


 if(function_exists(‘date_default_timezone_set’)) {
date_default_timezone_set(“Asia/Kolkata”);
}

$date = date(“d/m/Y”);
$time =  date(“H:i a”);
global $wpdb;
$table_name = $wpdb->prefix . “logintime”;
$wpdb->insert($table_name, array(‘start_time’ => $date, ‘login_date’ => $time) );

Categories
Uncategorized

How to get(search) record in table with ajax via dropdown?

get(search) record in table with ajax via dropdown
Use in main file which you will create 

<script src=”<?php echo plugin_dir_url(__FILE__);?>/js/jquery.min.js”></script>
<script>

jQuery(document).ready(function($){
$(“.selectcustomer”).change(function(){
var name = $(“.selectcustomer”).val();

/* alert(name); */
var data = {
‘action’ : ‘showdata’,
‘custname’ : name,
};
var ajaxurl = $(“.ajaxurl”).val();
jQuery.post(ajaxurl, data, function(response) {

console.log(response);
$(“.customer-info”).html(response);

});
});
});
</script>

<body>
<div class=”wrapper”>
<div class=”wrap”>
<form action=”” method=”post”>
<div class=”col-3″>
<label>Customer Name</label>
<select class=”selectcustomer” name=”custname”>
<option>Select Name</option>
<?php
global $wpdb;

$result = $wpdb->get_results ( “SELECT * FROM wp_jaspreetsingh” );
foreach ( $result as $printr ) 
{
echo”<option>$printr->person_name</option>”;

}
?>
</select>
</div>
<div class=”customer-info”>
<div class=”col-3″>
<label>Customer Address</label>
<input type=”text” name=”customeraddress” placeholder=”Customer Address” value=””>
</div>
<div class=”col-3″>
<label>Contact Person</label>
<input type=”text” name=”contactperson” placeholder=”Contact Person” >
</div>
<div class=”col-3″>
<label>Customer Email</label>
<input type=”Email” name=”email” placeholder=”Email” value=””>
</div>
<div class=”col-3″>
<label>Phone</label>
<input type=”number” name=”phone” placeholder=”Phone” value=”” >
</div>
</div>

</form>
</div>
</div>
<body>

         Use in function.php file which is located in theme folder.

function showdata(){
$name=$_POST[‘custname’];
   

        global $wpdb;
        $result = $wpdb->get_results ( “SELECT * FROM wp_jaspreetsingh where person_name=’$name’ ” );
        foreach ( $result as $printr )   {
         
            }
      ?>

<div class=”customer-info”>
<div class=”col-3″>
<label>Customer Address</label>
<input type=”text” name=”customeraddress” placeholder=”Customer Address” value=”<?Php echo $printr->address; ?>”>
</div>
<div class=”col-3″>
<label>Contact Person</label>
<input type=”text” name=”contactperson” placeholder=”Contact Person” >
</div>
<div class=”col-3″>
<label>Customer Email</label>
<input type=”Email” name=”email” placeholder=”Email” value=”<?Php echo $printr->email; ?>”>
</div>
<div class=”col-3″>
<label>Phone</label>
<input type=”number” name=”phone” placeholder=”Phone” value=”<?Php echo $printr->phone; ?>” >
</div>
</div>

<?php
die();

}
add_action(‘wp_ajax_showdata’,’showdata’);
add_action(‘wp_ajax_nopriv_showdata’,’showdata’);

Categories
Uncategorized

How to use properly ajax in wordpress ?

                          use ajax in wordpress 

            Use in main.php file which you will create

<html>
<head>
<script src=”<?php echo plugin_dir_url(__FILE__);?>/js/jquery.min.js”></script>
<script>
jQuery(document).ready(function($){
$(“.select”).change(function(){
var name = $(“.select”).val();

alert(name);
var data = {
‘action’ : ‘showdata’,
‘name’ : name,
};
var ajaxurl = $(“.ajaxurl”).val();
jQuery.post(ajaxurl, data, function(response) {

console.log(response);
$(“.result”).val(response);

});
});
});

</script>

<style>
.wrap{

width:80%;
margin:auto;

}

</style>
<head>
<body>
<div class=”wrap”>
<select class=”select” >
<option value=”jaspreet”>jaspreet</option>
<option value=”Developer”>Developer</option>
<option value=”Hello”>Hello</option>
</select>
<div class=”demo”></div>
<input type=”hidden” class=”ajaxurl” value=”<?php echo admin_url(‘admin-ajax.php’);?>”>
<input type=”text” class=”result”>
</div>
</body>
</html>

Use in function.php file which is located in ———>>>>>>>>>> C:wamp64wwwhomewp-contentthemestwentynineteen

function showdata(){
$name=$_POST[‘name’];
echo “hello”.” “.$name;
die();
}
add_action(‘wp_ajax_showdata’,’showdata’);
add_action(‘wp_ajax_nopriv_showdata’,’showdata’);

Categories
Uncategorized

How to add options in select html tag(Drowdown) from database in wordpress?

add options in select html tag(Drowdown) from database in wordpress

<label>Customer Name</label>
<select>
<?php
global $wpdb;

$result = $wpdb->get_results ( “SELECT * FROM wp_jaspreetsingh ” );
foreach ( $result as $print ) 
{
echo”<option>$print->person_name</option>”;
}
?>
</select>

Categories
Uncategorized

How to create options is select html tag(drpopdown) in php?

create options is select html tag(drpopdown) in php

<select>
<?php

for($i=1;$i<=10;$i++){
 echo”<option>navi</option>”;
}
?></select>

Categories
Uncategorized

How TO Scroll Back To Top Button in wordpress?


Scroll Back To Top Button in wordpress

DOWNLOAD JS FILE from https://jquery.com/download/ =       jquery.min.js (jquery-3.4.1.js)

<html>
<head>
<style>

/****************************************
  IMPORTANT
*****************************************/

.scrollTop {
  position: fixed;
  right: 10%;
  bottom: 10px;
  background-color: #BE3F48;
  padding: 20px;
  opacity: 0;
  transition: all 0.4s ease-in-out 0s;
}

.scrollTop a {
  font-size: 18px;
  color: #fff;
}

</style>
<script src=”<?php echo plugin_dir_url(__FILE__);?>/js/jquery.min.js“></script>

<script>

// BY KAREN GRIGORYAN

$(document).ready(function() {
  /******************************
      BOTTOM SCROLL TOP BUTTON
   ******************************/

  // declare variable
  var scrollTop = $(“.scrollTop”);

  $(window).scroll(function() {
    // declare variable
    var topPos = $(this).scrollTop();

    // if user scrolls down – show scroll to top button
    if (topPos > 300) {
      $(scrollTop).css(“opacity”, “1”);

    } else {
      $(scrollTop).css(“opacity”, “0”);
    }

  }); // scroll END

  //Click event to scroll to top
  $(scrollTop).click(function() {
    $(‘html, body’).animate({
      scrollTop: 0
    }, 800);
    return false;

  }); // click() scroll top EMD

  /*************************************
    LEFT MENU SMOOTH SCROLL ANIMATION
   *************************************/
  // declare variable
  var h1 = $(“#h1”).position();
  var h2 = $(“#h2”).position();
  var h3 = $(“#h3”).position();

  $(‘.link1’).click(function() {
    $(‘html, body’).animate({
      scrollTop: h1.top
    }, 500);
    return false;

  }); // left menu link2 click() scroll END

  $(‘.link2’).click(function() {
    $(‘html, body’).animate({
      scrollTop: h2.top
    }, 500);
    return false;

  }); // left menu link2 click() scroll END

  $(‘.link3’).click(function() {
    $(‘html, body’).animate({
      scrollTop: h3.top
    }, 500);
    return false;

  }); // left menu link3 click() scroll END

}); // ready() END

</script>
</head>
<body>

  <div class=”right”>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
    <div>sdfdfsdfdfdsfdfsdfdfdfdsfdsf<div>
  </div>

  <div id=”stop” class=”scrollTop”>
    <span><a href=””>Top</a></span>
  </div>

<!– main–>

</body>
</html>

Categories
Uncategorized

How to get site url path in wordpress?

get site url path in wordpress

<?php echo site_url(); ?>
Categories
Uncategorized

How to get plugin path in wordpress?

get plugin path in wordpress

<?php echo plugin_dir_url(__FILE__);?>