How to sum two rows from database and output

Hello,

I want to count two rows from database and print as total count, the problem is i don’t know how to count the highlighted rows as total and echo.

What i do know is how to count the total cars from product like here below
Database: vote_product

$result = mysql_query("select sum(product LIKE '%cars%')as cars from vote_product
");

Which counts the total cars from database, what i want to know is how to count the highlighted values with red, which will output 72 as total votes, and that in a while loop.

Thanks in advance.

By while loop, you said a “for each row” ?

Here is the SQL for a sum of two value.

select sum(vote_down+vote_up) as total from vote_product where product like '%car%'

sqlfiddle example

1 Like

That is ok and good to know, but what i need is to select only the red one with total votes of 72

Thank for your fast reply. :grinning:

Thank you verry much i fix the problem, :grinning:

$pageID = $row['id'];

select sum(vote_down+vote_up) as total from vote_product where id = '$pageID'

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.