maths in php

Started on the old forum in June 2009 · view the original in the archive · old links redirect here

1 reply · 392 views · started 17 years ago · 1 min read

2 participants
crazybrumi Super moderator Principal · 1,064 posts #1
$addplus = mysql_fetch_array(mysql_query("SELECT rate,total FROM gallery_files WHERE id='".$id."'"));

    $addplus = $rate + $addplus[0];
    $total = $addplus[1] + 10;
    $res = mysql_query("UPDATE gallery_files SET rate= '".$addplus."', total = '".$total."' WHERE id='".$id."'");
    if($res){
    $main.="<p align=\"center\">";
    $main.="<img src=\"../phpThumb/phpThumb.php?src=../images/ok.gif\" alt=\"O\"/>You Have Rated This Picture Successfully<br/>";
    mysql_query("INSERT INTO rated SET id='".$id."', bywho='".getuid_sid($sid)."', value='".$rate."'"); 
    }

this dosnt want to add the 10 ontop of the saved scored in total. so every time some gets rated they get rated outa 10 so if 2 people rated them it would be rate/ out of 20 but the 20 wont updated to 30 when he next reate is done if u nw what i mean. :0 cheers folks.

Want something coded email me at sales@webnwaphost.com for a prices.

http://flagcounter.com/more/W80q

Anshul Senior · 296 posts #2

rate and total field are they int ?

second you can do this by in single line query

$update = mysql_query("UPDATE `gallery_files` SET `rate` = `rate` + $rate ,`total` = `total` + 10  WHERE `id` = '" . $logged['id'] . "';");

Write your reply now; next you create a free account (or sign in) and it is posted right away. Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close