Looking to built like counter

Looking to built like counter

Hi,
I need to build a like counter as like in facebook which increments value behind the page when like is clicked. Here also i want to do the same but here instead of "like" i want to make as "Pray" once clicked likes for that post should be incremented on database and here on user side(client side) Pray should be changed to "Prayed". And also a value i.e how many people prayed also incremented. here the code, i need to do all the things above mentioned. With this code i cant get exact message id to pass to behind the page and increment likes.
 
  1. <html>
    <head>
    <title></title>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
    <script src="js/slides.min.jquery.js"></script>
    <script>
    $(document).ready(function () {
    $(".pray").click( function()
    {
    var mid=$(this).val();
    alert("value="+mid);
    $.ajax(
    {
    type:"POST",
    url:"increment.php",
    data:'mid='+mid,
    success:function ()
    {
    $("div.pray").text("Prayed");
    }
    });
    });
    });
    </script>
    </head>
    <body>
    <?php

























  2. session_start();
    if(isset($_SESSION['usrid']))
    {
     $usr=$_SESSION['usrid'];
    include('dbcon.php');
    $cot="select * from posts where userid=$usr LIMIT 10";// order by eventDate DESC, eventHour DESC" LIMIT0,10";
    $ex=mysql_query($cot,$con);
    while($cont=mysql_fetch_array($ex))
    {
    $date = date_create($cont['date']);
    $mid=$cont['mid'];
    echo "<div id='posts'>";
    echo $cont['message'];
    echo $photo;
    echo "<div class='pray'>";
    echo "<input type='text' class='pray' value='$mid'>";
    echo "<a href='#'>Pray</a></div>";
    echo "Prayed(".$cont['prayers'].")&nbsp;&nbsp&nbsp;&nbsp";
    echo date_format($date, 'd-m-Y H:i:s');
    echo "<hr>";
    echo "</div>";
    }
    }
    else
    {
    echo "Login to see";
    }
    ?>
    </body>
    </html>