User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 423,520 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,398 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 1826 | Replies: 5
Reply
Join Date: Nov 2004
Posts: 229
Reputation: sam1 is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
sam1's Avatar
sam1 sam1 is offline Offline
Posting Whiz in Training

Solution Urgent help needed !!!

  #1  
Jan 2nd, 2005
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:
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Dec 2004
Location: Fort Bragg, NC
Posts: 189
Reputation: mikeSQL is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 3
mikeSQL's Avatar
mikeSQL mikeSQL is offline Offline
Junior Poster

Re: Urgent help needed !!!

  #2  
Jan 2nd, 2005
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!
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!;)
Reply With Quote  
Join Date: Jan 2005
Posts: 18
Reputation: demo is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 2
demo demo is offline Offline
Newbie Poster

Re: Urgent help needed !!!

  #3  
Jan 3rd, 2005
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!
Reply With Quote  
Join Date: Nov 2004
Posts: 229
Reputation: sam1 is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
sam1's Avatar
sam1 sam1 is offline Offline
Posting Whiz in Training

Re: Urgent help needed !!!

  #4  
Jan 3rd, 2005
so how can i restrict it so that a voter can only vote once!!!!!!!!!!!!!!!!!!!!!
Reply With Quote  
Join Date: Jan 2005
Posts: 18
Reputation: demo is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 2
demo demo is offline Offline
Newbie Poster

Re: Urgent help needed !!!

  #5  
Jan 3rd, 2005
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
Reply With Quote  
Join Date: Nov 2004
Posts: 229
Reputation: sam1 is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
sam1's Avatar
sam1 sam1 is offline Offline
Posting Whiz in Training

Re: Urgent help needed !!!

  #6  
Jan 3rd, 2005
yes plz if u got one example SHOW ME THANKS!!!!!!!
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb PHP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 5:01 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC