Polling in php, ajax, mysql – PHP

  php

Q(Question):

Hi all,

Can anyone send me a link/code for online polling in php. I am looking for good and graphical polling for my web-page.

Thanks in Advances..

A(Answer):

Hey.

Did you try a Google search? There are a lot of scripts like these out there.
This one looks promising.

A(Answer):

Hi Atli,
Thanks for replying,
I tried many, but not getting any good one, can u send me that downloaded file, i cant access download here. or please send me that code,
its urgent.
Thanks

A(Answer):

I don’t really have any files or scripts to send you. There are a lot of them available online, though, so you can just use Google and take your pick.

If none of them are working for you, you might need to create your own, or modify one of the existing once. I’m not going to do it for you, but if you run into problems doing it yourself, I am more than willing to try to help you solve them. Just post them here.

A(Answer):

Thanks for replying,

i m using ajax code for my polling system.

<input type="radio" name="vote" value="<?php echo $row['choice'];?>" size="1" onclick="showUser(this.value,'<?php echo $row_['id'];?>')"/>

Ajax code of some lines:

var url="poll.php";
url=url+"?q="+str;
url=url+"&q1="+value;
xmlhttp.onreadystatechange=stateChanged;

But i need to call my ajax function, on onclick submit button ie.

<input type="submit" name="submit" value="vote" />

can u tell me how to code here on submit input type.

Thanks again.

A(Answer):

You should rather use the form’s onsubmit event, rather than the submit buttons onclick event. That way you can stop the form from being submitted the old fashion way.

In your HTML, you could do something like:

<form onsubmit="return onsubmit_callback();">

Which might call a function like this:

function onsubmit_callback(e) {
// Do your AJAX call here
var url = 'formUpdateScript.php';
var data = $('form').eq(0).serializeArray( );
$.post(url, data, function(data, message)() {
if(message == 'success') {
alert('Success! Request returned: ' + data);
}
else {
alert('Update failed! (' + message +')');
}
}, 'text');
// Return FALSE when you are done.
// This prevents the form from being submitted
// the old fashion way.
// DO NOT FORGET THIS OR THIS WON'T WORK!
return false;
}

Note that I use jQuery for the AJAX example. It’s so much simpler than the native JavaScript syntax.

Pay special attention to the return value of the function. If it is not set to false, the form will be submitted as usual and you will not see the result of the AJAX query.

A(Answer):

Thanks you soo much, Its really help for me. Now i got some idea, i hope it will work.

LEAVE A COMMENT