Changeset 210 for quests/action.php


Ignore:
Timestamp:
Jan 12, 2008, 12:24:07 AM (17 years ago)
Author:
maron
Message:

Hlasování pomocí známek 1-5

File:
1 edited

Legend:

Unmodified
Added
Removed
  • quests/action.php

    r208 r210  
    2020    $IDuser = $_SESSION['UserID'];
    2121
    22     if ($vote <> 1 and $vote <> -1 and Licence(1) == False) die('');
     22  //  if (Licence(0)) die('Hlasovat mùžou jenom registrovaní!');
    2323
    2424
    25     $Line = mysql_fetch_row($Database->SQLCommand("SELECT * FROM vote WHERE IDuser = '$IDuser' AND ID = '$questID'"));
    26     if (!$Line) {
    27    
    28     $Line = mysql_fetch_array($Database->SQLCommand("SELECT Vote FROM quests WHERE ID = '$questID'"));
     25    $Line = mysql_fetch_row($Database->SQLCommand("SELECT * FROM vote WHERE IDuser = '$IDuser' AND IDquest = '$questID'"));
     26    if (!$Line) { 
     27      $Line = mysql_fetch_array($Database->SQLCommand("SELECT Vote,CountVote FROM quests WHERE ID = '$questID'"));
     28      $CountVote = $Line['CountVote']+1;
     29      $OldVote = $Line['Vote']*$Line['CountVote'];
     30      $NewVote = ($OldVote+$vote)/$CountVote;
    2931     
    30       $vote = $Line['Vote']+$vote;
     32      echo $NewVote;
    3133
    32       $Database->SQLCommand("UPDATE quests SET Vote = '$vote' WHERE ID = '$questID'");
     34      $Database->SQLCommand("UPDATE quests SET Vote = '$NewVote', CountVote = '$CountVote' WHERE ID = '$questID'");
    3335   
    3436      $Database->SQLCommand("INSERT INTO `vote` ( `IDquest` , `IDuser` , `vote` ) VALUES ( '$questID', '$IDuser', '$vote');");
Note: See TracChangeset for help on using the changeset viewer.