Jump to content

Recommended Posts

Hello! i am trying to create a music chart for my site, and its frustrating ive found almost nothing that can help so far!

 

it sounds simple, basically, each band will have their own profile, somewhere on the page you'll be able to give them a vote, this vote will be sent to the full chart of all the bands which will order itself accordingly into top 100, with the band with the most votes at the top and the least votes at the bottom.

 

any ideas or questions?! please reply!

Link to comment
https://forums.phpfreaks.com/topic/50697-music-chart/
Share on other sites

start off with 3 tables

 

Users:

------

userid

username

password

email

...

 

Profile:

userid

profile

website

photo

...

 

Rate:

rid

userid

rating

...

 

Take a look at my site: www.SyracuseBands.net you might get some other ideas too

 

Hope this gets you started in the right direction

Link to comment
https://forums.phpfreaks.com/topic/50697-music-chart/#findComment-249220
Share on other sites

yea this is actually pretty simple.

 

on the vote page just do an update query or someting

 

$bands = mysql_query("SELECT * FROM bands WHERE bandname = '$_GET[bandname]'");

while ($band = mysql_fetch_array($bands)) {

mysql_query("UPDATE `bands` SET `votes` = '$band[votes] + 1' WHERE `bandbame` = '$_GET[bandname]'"); }

 

now to order 100 starting with the first on just do

 

$bands = mysql_query("SELECT * FROM bands WHERE bandname = '$_GET[bandname]' ORDER BY votes DESC LIMIT 100'");

while ($band = mysql_fetch_array($bands)) {

echo "$band[bandname]

<br />

\n";

}

 

edit bold bits

Link to comment
https://forums.phpfreaks.com/topic/50697-music-chart/#findComment-249227
Share on other sites

here is my top 10 rating query:

 

SELECT rate.bandid, count(rate.bandid) as totalcount, avg( rate.rating ) as average, users.name FROM rate INNER JOIN users on (users.userid = rate.bandid) WHERE users . type = 'b' GROUP BY rate.bandid having totalcount >= 10 ORDER BY average DESC, users.name ASC LIMIT 10

Link to comment
https://forums.phpfreaks.com/topic/50697-music-chart/#findComment-249229
Share on other sites

i cant send personal messages apparently!

 

i'm thinking there must be a simple way of doing this! i was mucking around with this one voting system which use a text file to read and write the amount of votes.

 

problems with this were, i couldnt have it so you can only vote for one band and have it update just that one band in the document containing all the bands and votes (dont know if that makes sense)

 

and the other problem is it doesn't put them in order of highest vote, it just puts the amount of votes after it.

 

the text file is set out like this

 

PollQuestion

Pollanswer1:0

Pollanswer2:0

Pollanswer3:0

Pollanswer4:0

 

concrete example;

 

what is your favourite colour?

red:0

blue:0

green:0

 

this is the code:

 

 

 

 

<?php

/*************************************************

* Micro Polling System

*

* Version: 1.0

* Date: 2007-04-05

*

* Usage:

* Add your votings settings to polldata.txt file

* The first line is the question and the other

* linas are the possible answers.

*

****************************************************/

 

$pollQuestion = '';

$answers = '';

 

function readData(){

global $pollQuestion,$answers;

// Read configuration

$rawdata = file('polldata.txt');

// Get the question for polling

$pollQuestion = $rawdata[0];

 

// Get number of answers - The foirs row is the question

$numberOfAnswers = sizeof($rawdata)-1;

$count = 0;

for ($i=1; $i <= $numberOfAnswers; $i++){

$answerData = explode(':',$rawdata[$i]);

// If tha actual row is not empty than add to the answers array

if (strlen(trim($answerData[0]))>0){

$answers[$count]['text']  = $answerData[0];

$answers[$count]['count'] = $answerData[1];

++$count;

}

}

}

 

function writeData(){

global $pollQuestion,$answers;

$file = fopen('polldata.txt','w');

fwrite($file,$pollQuestion."\r\n",strlen($pollQuestion));

foreach ($answers as $value) {

$row = $value['text'].':'.$value['count']."\r\n";

fwrite($file,$row,strlen($row));

}

fclose($file);

}

 

readData();

?>

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">

<html>

<head>

  <title>Micro Polling System</title>

  <link href="style/style.css" rel="stylesheet" type="text/css" />

</head>

<body>

    <div id="main">

<?php if (!isset($_POST['submitBtn'])) { ?>     

      <div class="caption"><?php echo $pollQuestion; ?></div>

      <div id="icon"> </div>

      <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="poll">

        <table width="300">

        <?php

        foreach ($answers as $value) {

echo '<tr><td><input type="radio" name="polling" value="'.$value['text'].'"/> '.$value['text'].'</td></tr>';

        }

        ?>

          <tr><td align="center"><br/><input class="text" type="submit" name="submitBtn" value="Vote" /></td></tr>

        </table> 

      </form>

<?php   

} else {

    $count = 0;

      foreach ($answers as $value) {

if ($value['text']  == $_POST['polling']) {

$answers[$count]['count'] = ((int)$value['count'])+1;

(int)$totalCount++;

}

++$count;

      }

     

      writeData();

?>

      <div class="caption">Thanks for your vote!</div>

      <div id="icon"> </div>

      <div id="result">

        <table width="300">

<?php

      foreach ($answers as $value) {

echo '<tr><td> '.$value['text'].'</td><td>'.$value['count'].'</td></tr>';

      }

?>

        </table>

    </div>

<?php } ?>

<div id="source">Micro Polling System 1.0</div>

    </div>

</body> 

 

 

 

 

what do you think?

Link to comment
https://forums.phpfreaks.com/topic/50697-music-chart/#findComment-249276
Share on other sites

ok, im not doing too well at making this table!

 

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') VALUES('1', '1')' at line 2

 

hmm...if i make an sql table here can i transfer it to other servers??

Link to comment
https://forums.phpfreaks.com/topic/50697-music-chart/#findComment-250006
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.