Skip to main content

Get Google Calendar Event List in WordPress

<a href="https://console.cloud.google.com/apis/credentials">Get Your Api Credentials Here</a> <a href="https://calendar.google.com/calendar">Get your Calender ID</a> <?php include_once("wp-load.php"); function  get_calender_events() { $params = array(); /*Get current date*/ $current_date  = date('Y-m-d H:i:s'); /*Convert it to google calendar's rfc_format */ $rfc_format = date("c", strtotime($current_date)); $params[] = 'orderBy=startTime'; $params[] ='maxResults=100'; $params[] = 'timeMin='.urlencode($rfc_format); $url_param = ''; foreach($params as $param) { $url_param.= '&'.$param; } $calender_id = "calender_id"; $client_key =  "client_key"; $url = "https://www.googleapis.com/calendar/v3/calendars/".$calender_id."/events?key=".$client_key."&singleEvents=true".$url_param; $list_events = wp_remote_post($url, ...

Auto suggestion using Ajax, jQuery and PHP

jQuery PHP Ajax Autosuggest
Search.html
<input type="text" class="searchfield search_keyword"  placeholder="Search For Stocks" id="search_keyword_id">
 <div id="result"></div>
    
    
<script type="text/javascript" src="//code.jquery.com/jquery-1.8.0.min.js"></script>
<script type="text/javascript">
function set_item(x,y,z)
{
 var c = x+"    "+ y;
 $('#search_keyword_id').val(c);
 $('#stockcode').val(x);
 $('#exchangeId').val(z);
}
$(function(){
$(".search_keyword").keyup(function()
{
    var search_keyword_value = $(this).val();
    var dataString = 'search_keyword='+ search_keyword_value;
    if(search_keyword_value!='')
    {
        $.ajax({
            type: "POST",
            url: "search.php",
            data: dataString,
            cache: false,
            success: function(html)
                {
                    $("#result").html(html).show();
                }
        });
    }
    return false;   
});

$(document).live("click", function(e) {
    var $clicked = $(e.target);
    if (! $clicked.hasClass("search_keyword")){
        $("#result").fadeOut();
        $("#results").fadeOut();
    }
});

$('#search_keyword_id').click(function(){
    $("#result").fadeIn();
});
});
</script>
***************
search.php
<?php
  define('_HOST_NAME', 'localhost');
    define('_DATABASE_USER_NAME', root);
    define('_DATABASE_PASSWORD', '');
    define('_DATABASE_NAME', 'demo');

    $dbConnection = new mysqli(_HOST_NAME, _DATABASE_USER_NAME, _DATABASE_PASSWORD, _DATABASE_NAME);
    if ($dbConnection->connect_error) {
        trigger_error('Connection Failed: '  . $dbConnection->connect_error, E_USER_ERROR);
    }

          extract($_POST);
    if(isset($_POST['search_keyword']))
    {
        $search_keyword = $dbConnection->real_escape_string($_POST['search_keyword']);
        $sqlCountries="SELECT *  FROM `company_list` WHERE `CompanyName` LIKE '%$search_keyword%' OR `Symbol` LIKE '$search_keyword%'";
   
        $resCountries=$dbConnection->query($sqlCountries);

        if($resCountries === false) {
            trigger_error('Error: ' . $dbConnection->error, E_USER_ERROR);
        }else{
            $rows_returned = $resCountries->num_rows;
        }

 $bold_search_keyword = '<strong>'.$search_keyword.'</strong>';
 if($rows_returned > 0){
            while($rowCountries = $resCountries->fetch_assoc())
            {
   $cname = explode(" ", $rowCountries['CompanyName']);
   if(strpos(strtolower ($cname[0]), strtolower ($search_keyword)) == 0 && strpos(strtolower ($cname[1]), strtolower ($search_keyword)) == 0 && strpos(strtolower ($cname[2]), strtolower ($search_keyword)) == 0 && strpos(strtolower ($cname[3]), strtolower ($search_keyword)) == 0 && strpos(strtolower ($cname[4]), strtolower ($search_keyword)) == 0 && strpos(strtolower ($cname[6]), strtolower ($search_keyword)) == 0 && strpos(strtolower ($cname[7]), strtolower ($search_keyword)) == 0 && strpos(strtolower ($cname[8]), strtolower ($search_keyword)) == 0)
   {
                echo '<div class="show" align="left" onclick="set_item(\''.str_replace("'", "\'", $rowCountries['Symbol']).'\',\''.str_replace("'", "\'", $rowCountries['CompanyName']).'\',\''.str_replace("'", "\'", $rowCountries['ExchangeId']).'\')" ><div class="country_left">'.str_ireplace($search_keyword,$bold_search_keyword,$rowCountries['Symbol']).'</div><div class="country_right">'. str_ireplace($search_keyword,$bold_search_keyword,$rowCountries['CompanyName']).'</div><div class="country_rights">     Equity - '. str_ireplace($search_keyword,$bold_search_keyword,$rowCountries['ExchangeId']).'</div></div>';
            }
 
 
   }
        }else{
          //  echo '<div class="show" align="left">No matching records.</div>';
        }
    }
?>

 

Comments

Popular posts from this blog

Create Signature pad with save on database in php

Create Signature pad with save on database in php 1.create a folder images index.php ============   <!DOCTYPE >     <head>     <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />     <title>Signature Pad</title>     <script type="text/javascript" src="jquery-1.8.0.min.js"></script>     <script type="text/javascript"> $(document).ready(function () {     /** Set Canvas Size **/     var canvasWidth = 400;     var canvasHeight = 100;     /** IE SUPPORT **/     var canvasDiv = document.getElementById('signaturePad');     canvas = document.createElement('canvas');     canvas.setAttribute('width', canvasWidth);     canvas.setAttribute('height', canvasHeight);     canvas.setAttribute('id', 'canvas');     canvasDiv.appendChild(canvas);    ...

Get Google Calendar Event List in WordPress

<a href="https://console.cloud.google.com/apis/credentials">Get Your Api Credentials Here</a> <a href="https://calendar.google.com/calendar">Get your Calender ID</a> <?php include_once("wp-load.php"); function  get_calender_events() { $params = array(); /*Get current date*/ $current_date  = date('Y-m-d H:i:s'); /*Convert it to google calendar's rfc_format */ $rfc_format = date("c", strtotime($current_date)); $params[] = 'orderBy=startTime'; $params[] ='maxResults=100'; $params[] = 'timeMin='.urlencode($rfc_format); $url_param = ''; foreach($params as $param) { $url_param.= '&'.$param; } $calender_id = "calender_id"; $client_key =  "client_key"; $url = "https://www.googleapis.com/calendar/v3/calendars/".$calender_id."/events?key=".$client_key."&singleEvents=true".$url_param; $list_events = wp_remote_post($url, ...

WooCommerce Mini cart With Ajax

WooCommerce Mini cart //MINI CART SECTION   <div class="productdiv rightcart">                                                         <?php if ( ! WC()->cart->is_empty() ) : ?>     <ul class="woocommerce-mini-cart cart_list product_list_widget <?php echo esc_attr( $args['list_class'] ); ?>">         <?php             do_action( 'woocommerce_before_mini_cart_contents' );             foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {                 $_product     = apply_filters( 'woocommerce_cart_item_pro...