Jump to content

help with a rating system


mikeromero

Recommended Posts

hey so im just trying to figure out how to get a rating system working so that i can put it in my site...but im having some problems getting it to work...

for some reason it just wont submit the data when i press any of the buttons to vote :/

i think the problem is that im just not defining the "mode" variable the right way, because when i put "echo $mode", it doesnt do anythin. it just appears blank.  :wtf:

so anyways, heres the code ive got. hopefully someone can tell me what im doing wrong!

 

<?php

mysql_connect("localhost", "user", "pass")or die(mysql_error());

mysql_select_db("rating") or die(mysql_error());

 

Echo $mode;

if($mode==vote){

mysql_query ("UPDATE vote SET total = total+$voted, votes = votes+1 WHERE id = $id");

Echo "Your vote has been cast <p>";

}

 

 

$data = mysql_query("SELECT * FROM vote") or die(mysql_error());

while($ratings = mysql_fetch_array( $data )) {  Echo "Name: " .$ratings['name']."<br>";

$current = $ratings[total] / $ratings[votes];

Echo "Current Rating: " . round($current, 1) . "<br>";

Echo "Rank Me: ";

Echo "<a href=".$_SERVER['PHP_SELF']."?mode=vote&voted=1&id=".$ratings[id].">Vote 1</a> | ";

Echo "<a href=".$_SERVER['PHP_SELF']."?mode=vote&voted=2&id=".$ratings[id].">Vote 2</a> | ";

Echo "<a href=".$_SERVER['PHP_SELF']."?mode=vote&voted=3&id=".$ratings[id].">Vote 3</a> | ";

Echo "<a href=".$_SERVER['PHP_SELF']."?mode=vote&voted=4&id=".$ratings[id].">Vote 4</a> | ";

Echo "<a href=".$_SERVER['PHP_SELF']."?$mode=vote>Vote 5</a><p>"; } ?>

 

 

-thanks

mike

Link to comment
https://forums.phpfreaks.com/topic/207781-help-with-a-rating-system/
Share on other sites

Echo "<a href=".$_SERVER['PHP_SELF']."?mode=vote&voted=4&id=".$ratings[id].">Vote 4</a> | ";

 

doesnt that assign  $mode to "vote" and also  $voted  to 4 when you click that link?

or is that what im doing wrong maybe?

 

...sorry im kinda a newb at this  :shrug:

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.