How do you subtract one Integer Variable from another?
Posted: Sat Aug 01, 2009 5:12 am
I want to subtract a number in the DOWNVOTES from the UPVOTES from a SQL table and show the answer.
I'm guessn' you can't perform arithmetic in HTML, the only option is JavaScript, unless you can do it in PHP while echoing a table of data.
This is my JavaScript attempt, but of course it doesn't work.
echo " <td><script type='text/javascript'>v=($row['UPVOTES'])-($row['DOWNVOTES']) document.write(v)</script></td>\n";
1) Can you perform arithmetic on 2 $row variables with PHP before echoing the result (instead of using JavaScript)?
2) IF NOT, how could I get the above code working?
Thanx
I'm guessn' you can't perform arithmetic in HTML, the only option is JavaScript, unless you can do it in PHP while echoing a table of data.
This is my JavaScript attempt, but of course it doesn't work.
echo " <td><script type='text/javascript'>v=($row['UPVOTES'])-($row['DOWNVOTES']) document.write(v)</script></td>\n";
1) Can you perform arithmetic on 2 $row variables with PHP before echoing the result (instead of using JavaScript)?
2) IF NOT, how could I get the above code working?
Thanx