A question for website design gurus

Started by aussie, Sat 15/04/2006 15:03:02

Previous topic - Next topic

Radiant

Quote from: BOYD1981 on Sun 16/04/2006 15:05:06
hmm, for some reason i think it's Queen's "princes of the universe" song, the one from Highlander...

Pretty close, but no cigar.

aussie

And to think this thread was just an innocent question about web polls...
It's not the size of the dog in the fight. It's the size of the fight in the dog.

http://www.freewebs.com/aussiesoft/

Kinoko

Radient: The VERY first thing that popped into my head, before I even read the second line of the lyrics, was "Seven Seas of Rhye" by Queen. I went and re-read the lyrics to that song and I feel like I'm right, but... obviously, it's hard to tell :P

Radiant

I'm amazed that two individual people immediately recognize Queen; I would have thought that was impossible after all the babelized garbling.

Spoiler

The song was Bohemian Rhapsody, by the way.
[close]

seaduck

Quote from: Radiant on Sat 15/04/2006 19:57:14
You don't need SQL or indeed any databasing system (of course you could use that as well, but it requires learning SQL). The easiest to do is this:

Create a flat datafile that has several lines that go "name of game, amount of votes, average". Upon page load, read from that file into a STRUCT or CLASS and display the result as a HTML table. Upon receiving any votes, recalculate the averages ((cur_avg * amt_votes) + new_vote) / (amt_votes + 1), and overwrite the file with the structs in descending order of votes (sort on write is more efficient than sort on read). This is all just basic math and file IO, so you don't need to be a coding wiz to figure it.

This should work for the most part, but I'm afraid we have a race condition here. Keep in mind that if multiple users get the page at the same time, the web server will IMO launch the same script multiple times at once. The interleaved IO migh even corrupt the contents of the file in the worst case... So unless there is a file-locking feature in PHP (is there? I never heard of it) and you use it, this might go wrong once in a while.

With MySQL you can make sure the data stay consistent quite easily. It needs a very basic understanding of databases, but it's actually simpler than using file io...

Radiant

Quote from: seaduck on Mon 17/04/2006 13:44:36
This should work for the most part, but I'm afraid we have a race condition here. Keep in mind that if multiple users get the page at the same time, the web server will IMO launch the same script multiple times at once. The interleaved IO migh even corrupt the contents of the file in the worst case...

On any decent file system, this cannot and will not cause data corruption. However, it is true that if two users access the page simultaneously (as in, within a few milliseconds), then the vote of either of them might be lost. Given the speed and near-atomicity of the operation, this is exceedingly unlikely. I've ran a forum that worked like this for a year and never had a problem.

Still, for any professional or commercial site, SQL is the proper solution.

Oneway

In an effort to get this topic back to the actual topic:

hotscripts is your friend:
http://www.hotscripts.com/PHP/Scripts_and_Programs/Polls_and_Voting/index.html

You'll most definately need to learn some php coding to customize things, but the basics are there won't make you invent the wheel all over again.
Almost intentionally left blank.

rharpe

Quote from: Kinoko
Okay Rolf, I find your posts the most entertaining thing on AGS right now, but...

Please, stop using Babelfish to translate them into to English! We can't understand you. Your posts don't make sense.

God, I hope that English was simple enough to get through. What language does he speak? Does anyone else speak it? I think someone needs to tell him.
Kinoko, does it really matter? You can make it out to whatever you want him to say. I, too, find it entertaining! But he needs to say things in less words... that may help. (IE: I am hungry... or AGS is good... or I made game... or I leave now... etc.)

Rolf, keep it simple, you'll catch on.  (I feel like I'm teaching Encino Man.) ;)
"Hail to the king, baby!"

SMF spam blocked by CleanTalk