I want to set up a feature on my site where users see a list, like the top 10 best selling songs, and then vote themselves. The 'original' Top 10 and the visitors Top 10 will be displayed side-by-side.

This is best illustrated with an example:

Chart Position      Visitor Position   Song
-------------------------------------------------------
1                   10                 Insomnia
2                   1                  Enter Sandman
3                   2                  Bad Moon Rising
4                   5                  Sunchyme
5                   3                  Beautiful Stranger
6                   4                  One
7                   6                  Wild Thing
8                   9                  Answer the Phone
9                   7                  Feel It
10                  8                  Can't get enough...
So, visitors to the site vote for their favourite song by selecting it from a menu somewhere. I can't believe this simple thing is so difficult to code.

I have a plain text file for each song which contains the 'fixed position', i.e. the chart position, and the current visitors' position. When a user votes, the relevant file is opened, and the visitor position incremented.

I've tried using different arrays, but I can't sort them both in the same way as they get "out of sync". So I tried using a hash like $song{$chart_position}{$name}, but I couldn't figure the sorting out. (It should be in order of the chart position).

I'm really going mad trying to figure this out, so I'd appreciate any help.

(Please do not suggest using a database or something, I just really want to keep this simple)


In reply to Fixed 'Top 10' compared with visitors' Top 10 by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.