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
How do you subtract one Integer Variable from another?
Moderator: General Moderators
-
Paradox187x
- Forum Newbie
- Posts: 7
- Joined: Mon Jul 20, 2009 6:24 am
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
Re: How do you subtract one Integer Variable from another?
Code: Select all
$v = $row['UPVOTES'] - $row['DOWNVOTES'];
echo $v;
-
Paradox187x
- Forum Newbie
- Posts: 7
- Joined: Mon Jul 20, 2009 6:24 am
Re: How do you subtract one Integer Variable from another?
Thanx,
I don't know why I have to over complicate things
I don't know why I have to over complicate things