Jump to content

if i vote on one user , this vote goes to all users . need help


mmmrafik

Recommended Posts

<?php 
// Connects to your Database 
mysql_connect("localhost", "dbusername", "dbpassword") or die(mysql_error()); 
mysql_select_db("mydatabase") or die(mysql_error()); 

//We only run this code if the user has just clicked a voting link
if ( $mode=="vote") 
{ 

//If the user has already voted on the particular thing, we do not allow them to vote     again    
    //$cookie = "Mysite$id"; 
if(isset($_COOKIE[$cookie])) 
    { 
    Echo "Sorry You have already ranked that site <p>"; 
    } 

//Otherwise, we set a cooking telling us they have now voted 
else 
    { 
    $month = 2592000 + time(); 
    setcookie('Mysite'.$id, 'Voted', $month); 

     //Then we update the voting information by adding 1 to the total votes     and adding their vote (1,2,3,etc) to the total rating 

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

    } 
} 
  if ( $mode2=="vote") 
{ 

//If the user has already voted on the particular thing, we do not allow them to vote     again    
    //$cookie = "Mysite$id"; 
if(isset($_COOKIE[$cookie])) 
    { 
    Echo "Sorry You have already ranked that site <p>"; 
    } 

//Otherwise, we set a cooking telling us they have now voted 
else 
    { 
    $month = 2592000 + time(); 
    setcookie('Mysite'.$id, 'Voted', $month); 

     //Then we update the voting information by adding 1 to the total votes     and adding their vote (1,2,3,etc) to the total rating 

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

    } 
}  

//Puts SQL Data into an array
$data = mysql_query("SELECT * FROM userads WHERE id = $id ") or die(mysql_error()); 

//Now we loop through all the data 
while($ratings = mysql_fetch_array( $data )) 

?>
<link href="style.css" type="text/css" rel="stylesheet" />
{ 
<?php
echo '<div id="voting_14" class="voting voting_template_votess-up-down">';
echo "<strong class='positive_votes'>";
$current = $ratings[votes];
echo "<span>+" . round($current,0) . "</span>";
echo "<a href=".$_SERVER['PHP_SELF']."?mode=vote&voted=1&id=".$ratings[id].">       <input class='vote_positive' type='submit'></a>";
echo '</strong>';

echo "<strong class='negative_votes'>";
$current2 = $ratings[nvotes]; 
echo "<a href=".$_SERVER['PHP_SELF']."?mode2=vote&voted=2&id=".$ratings[id].">      <input class='vote_negative' type='submit'></a>";
echo "<span>-". round($current2,0) ."</span>";
echo '</strong>';

echo '</div>';

} 
?>

i have sql table userads with : id , name , username , total, votes , nvotes.

Link to comment
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.