943,400 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 2447
  • PHP RSS
Jan 2nd, 2005
0

Urgent help needed !!!

Expand Post »
hello
I have created a website where voters vote for their favourite website. I have used radiobox.
does anyone know how to count the votes in terms of percentage after the user has voted. The result should come up in a new webpage.
Also the website should not allow a voter to vote more than once. thank you all :cry: :cry: :cry: :cry:
Similar Threads
Reputation Points: 10
Solved Threads: 1
Posting Whiz
sam1 is offline Offline
300 posts
since Nov 2004
Jan 2nd, 2005
0

Re: Urgent help needed !!!

Is thesite running on PHP and MySQL? or does it at lesat run on some sort of Database so that once the button IE; the form, the info goes to the database and updates itself.
Then you can have a script to call it grabbing the info and showing up on your site.

Not unless your using something like java or whatever, then i dunno. LOL!
Reputation Points: 16
Solved Threads: 3
Junior Poster
mikeSQL is offline Offline
196 posts
since Dec 2004
Jan 3rd, 2005
0

Re: Urgent help needed !!!

Hi

This is very basic math

100 [%] * [each selection total votes] / [the total votes for all selections]

example

say you have 5 website in your poll

site 1 -> total votes = 10
site 2 -> total votes = 6
site 3 -> total votes = 44
site 4 -> total votes = 68
site 5 -> total votes = 22

total votes = 150

// so now you have have everything to get the results!

example in PHP -> If you want it in different language just tell me which one!

[php]
<?

$result = array ( '10', '6', '44', '68', '22' );

$total = array_sum ( $result );

for ( $i = 0; $i < sizeof ( $result ); $i++ )
{
$percent = ( int ) ( 100 * $result[$i] / $total );

echo "SITE " . ( $i + 1 ) . ": " . $percent . "%\n<br />\n";
}

?>
[/php]


J!
Reputation Points: 10
Solved Threads: 2
Newbie Poster
demo is offline Offline
18 posts
since Jan 2005
Jan 3rd, 2005
0

Re: Urgent help needed !!!

so how can i restrict it so that a voter can only vote once!!!!!!!!!!!!!!!!!!!!!
Reputation Points: 10
Solved Threads: 1
Posting Whiz
sam1 is offline Offline
300 posts
since Nov 2004
Jan 3rd, 2005
0

Re: Urgent help needed !!!

Hi

This will really depend on how you wish to control this, and also what kind of service you will use this on!

voting control...

1. if this is used in a session type service -> ie: username and password -> then use the username!
2. if this is not used in a session type service, then use a 'IP' flag or a cookie, if you find the visitor has cookies turned on!

Here are a few problems with (#2)...

1. Cookies are turned off via the browser on average 3 out of 10 visitors!
2. A 'IP' can (1) change or (2) be a member of forwarding proxy that many visitors will be using as the same 'IP'

Now (#2) is better because you should never base anything on what you can not control, such as javascript or cookies!

(#2) will be somewhat flawed unless your using it in a protected member type enviroment, but it will still give the best result for a simple poll!


If you would like an example of a simple 'MULTI POLL HANDLER' script with a simple but powerful 'Admin Manager', just tell me and I will whip up a quick one!

John
Reputation Points: 10
Solved Threads: 2
Newbie Poster
demo is offline Offline
18 posts
since Jan 2005
Jan 3rd, 2005
0

Re: Urgent help needed !!!

yes plz if u got one example SHOW ME THANKS!!!!!!!
Reputation Points: 10
Solved Threads: 1
Posting Whiz
sam1 is offline Offline
300 posts
since Nov 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Converting from VB6 - php XOR Problem
Next Thread in PHP Forum Timeline: Help on moving tables from one server to another





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC