GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   PHP / MySQL Gurus : Help me inside. (https://gfy.com/showthread.php?t=440267)

galleryseek 03-05-2005 10:14 AM

PHP / MySQL Gurus : Help me inside.
 
$query = "UPDATE `hgarticlerate` SET votes=votes+1, score='hgarticlerate.votes/($vote+hgarticlerate.score)' WHERE articleid='15'";

now I know this has to be wrong, because I've never done anything like it and I couldn't find anything on the net about it (and uhm, yeah i tried running it and it also doesn't work :winkwink:)

basically what i'm trying to do for field "score" is perform an average by first adding the current value of "score" (hgarticlerate.score) to the new vote submitted ($vote), and then dividing it by the votes field (hgarticlerate.votes)

i'm sure i just have the syntax screwed up, or I'm leaving out a function in mysql that will do this easier. help?

vending_machine 03-05-2005 10:28 AM

Your code would look like this (you have your arithmetic wrong for the score, you will have to fix that ;) ):

Code:

UPDATE `hgarticlerate` SET votes = votes + 1 , score = votes / ( '$vote' + score ) WHERE articleid = '15';

galleryseek 03-05-2005 10:44 AM

Quote:

Originally Posted by vending_machine
(you have your arithmetic wrong for the score, you will have to fix that ;) ):

how is it wrong??

thanks btw.


All times are GMT -7. The time now is 05:34 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123