| | |
Urgent help needed !!!
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
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:
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:
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!
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!
dynastyCODERS#1 when it comes to Programming Tutorials, Database designs and discussions, Operating Systems, you name it, check us out and drop us a line to tell us your opinions on any and everything in mind!;)
•
•
Join Date: Jan 2005
Posts: 18
Reputation:
Solved Threads: 2
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!
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!
•
•
Join Date: Jan 2005
Posts: 18
Reputation:
Solved Threads: 2
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
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
![]() |
Similar Threads
- Urgent Help Needed on Project (Java)
- FRONTECH tv tuner card - stuck lost - urgent help needed (PCI and Add-In Cards)
- Urgent help is needed SQL datatypes (Database Design)
- Urgent help needed regarding executing Scripts in AJAX response (JavaScript / DHTML / AJAX)
- URGENT HELP NEEDED - critically important...!!! (Windows NT / 2000 / XP)
- extreme urgent help needed (Geeks' Lounge)
- Urgent help needed (Database Design)
- URGENT Help Needed With TicTacToe Application Source Code!!! (Java)
Other Threads in the PHP Forum
- Previous Thread: I want to make free subscription area
- Next Thread: Help on moving tables from one server to another
| Thread Tools | Search this Thread |
advanced ajax apache api array basics beginner binary broken cakephp check checkbox class cms code combobox cookies cron curl database date datepart display dynamic echo email error file files folder form forms function functions google head href htaccess html image include includingmysecondfileinthechain insert integration ip java javascript job joomla js limit link login loop mail menu mlm multiple mysql oop parse password paypal pdf php problem procedure query radio random recursion regex remote script search server sessions smarty smash sms soap source space sql stored syntax system table traffic tutorial unicode update upload url validator variable video web xml youtube





