How to track clicks on a facebook like button

Sometime its necessary to check whether someone clicks on or makes like on the facebook like button

and the facebook provide an call back function

this is the normal code to add facebook like button

<div id="fb-root"></div>
<script type="text/javascript">
(function() {
 var e = document.createElement('script');
 e.type = 'text/javascript';
 e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
 e.async = true;
 document.getElementById('fb-root').appendChild(e);
 }());
</script>
<fb:like href="URL" layout="standard|button_count" show-faces="true|false"
 width="450" action="like|recommend" colorscheme="light|dark"
font="arial|lucida grande|segoe ui|tahoma|trebuchet ms|verdana"></fb:like>

By adding this snippet of code to the above code we can track the likes

window.fbAsyncInit = function() {
 FB.init({appId: 'YOUR_FACEBOOK_APP_ID', status: true, cookie: true, xfbml: true});
 FB.Event.subscribe('edge.create', function(href, widget) {
 // Do something, e.g. track the click on the "Like" button here
 alert('You just liked '+href);
 });
};

And we can only track the like as there is no method to track dislikes

Store Arrays in Database Php

When working with arrays its necessary to store an array in a MySQL field. Unfortunately, there is no way to directly pass in an array as a parameter..

in this case we have to use the function serialize and unserialize in php

To convert any array (or any object) into a string using PHP, call the serialize function:

$array = array( 1, 2, 3 );
$string = serialize( $array );
echo $string;

this will results in

a:3:{i:0;i:1;i:1;i:2;i:2;i:3;}

to convert back from the string to the array, use unserialize:

// $array will contain ( 1, 2, 3 )
$array = unserialize( $string );

This is how we can store Arrays in Database Php

Find next and previous date from current date PHP

I found an interesting new way to find a future or past day, month, or year using PHP.To recaps we can find next and previous date from current date PHP
Here are few examples

     //TODAY'S DATE
     $today=  date("Y-m-d");
 
     //NEXT MONTH FROM FIRST OF THIS MONTH
     $next= date("Y-m-d",strtotime('+1 months', strtotime(date('Y-m-01', strtotime($today)))));

     //PREV MONTH FROM FIRST OF THIS MONTH    
     $next= date("Y-m-d",strtotime('-1 months', strtotime(date('Y-m-01', strtotime($today)))));
 
     //GET NEXT 10 DAYS FROM TODAY
    $next= date("Y-m-d",strtotime('+10 days', strtotime($today)));
 
     //REMOVE THE RECORD 1 YEAR FROM TODAY
    $next= date("Y-m-d",strtotime('+1 years', strtotime($today)));

It is much easier than using a timestamp and mktime() to calculate a new date. By this we can find next and previous date from current date PHP

Add numbers or alphabets to google markers API

As part of Google Chart Tools we can generate markers that contain a letter or number, as well change the marker and font colors. So to recaps we can Add numbers or alphabets to Google markers API

Here the example code for this


<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
  function initialize() {
    var myLatlng = new google.maps.LatLng(-25.363882,131.044922);
    var myOptions = {
      zoom: 4,
      center: myLatlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    }
    var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
    
    var marker = new google.maps.Marker({
        position: myLatlng, 
        map: map,
        icon: 'http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=A|FF0000|000000'
    });   
  }
</script>
</head>
<body onload="initialize()">
  <div id="map_canvas"></div>
</body>
</html>

Here in the icon

‘A’ – The letter shown on the marker. This can also be a letter, a symbol, or a combination of them all.
‘FF0000′ – The hex color of the marker
’000000′ – The hex color of the font used

and the map will look like this

Hope this will help you to add numbers or alphabets to Google markers API