As you can see from the votes, this type of question doesn’t really fit well here at SO. We generally expect that you have code showing what you have tried so far and are asking for help with a specific issue you are facing.
That said, if I were you, I would use parse.com‘s services which will let you do this with just javascript.
Here is a post that will explain what you’d need to do to get setup with parse.
Here is a working jsFiddle showing how to save the votes
Code from that demo:
<input type="button" value="Red" class="vote"/>
<input type="button" value="Green" class="vote"/>
<input type="button" value="Blue" class="vote"/><br><br>
<div id="link"></div>
Parse.initialize("Application ID", "JavaScript key");
$('.vote').click(function(){
// create the `Parse` object
var ColorVote = Parse.Object.extend("ColorVote");
var _colorVote = new ColorVote();
// set the object's value to our button value
_colorVote.set("color", $(this).val());
// save the object
_colorVote.save(null, {
success: function(_colorVote) {
// if the save succeeded, give link to view results
$('#link').html('Vote saved! Please <a href="http://jsfiddle.net/DelightedDoD/ekgj2y5L/2/" target="_blank">click here</a> here to see the results of the vote so far.')
},
error: function(_colorVote, error) {
// save failed, do error handeling here
console.log('Failed to create new object, with error code: ' + error.message);
}
});
});
Here is a working jsFiddle showing how to display the saved votes
Code from that demo:
<div id="results"></div>
Parse.initialize("Application ID", "JavaScript key");
// create a query to search for our `ColorVote` items
var ColorVote = Parse.Object.extend("ColorVote");
var query = new Parse.Query(ColorVote);
query.limit(1000);
query.find({
success: function (results) {
var red =0, green =0, blue =0;
$.each(results, function(i,e){
if(e.get('color')=='Blue') blue++;
else if(e.get('color')=='Green') green++;
else if(e.get('color')=='Red') red++;
});
$('#results').html('Blue - '+blue+'<br>'+'Green - '+green+'<br>'+'Red - '+red+'<br>');
},
error: function (error) {
console.log("Error: " + error.code + " " + error.message);
}
});
1
solved jquery and php counting number of clicks and post the results in another page