Help needed in mysql

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

5 replies · 426 views · started 14 years ago · 1 min read

4 participants
amitdas333 Junior · 23 posts #1

Hi! Can anybody help me, i want to add the results of mysql_num_rows. $ad = ("SELECT * from campaigns WHERE id=$id) $result = mysql_num_rows($ad);

I wand to sum all the result. For example, if there are 5 results- 10 20 5 9 16

echo $result; It will show 5 result. I want to add all 5 results & show 60 as the result. I google a lot but couldn't get the answer. Plz help!!

razzbee Developer · 130 posts #2

I am sorry but I dont seem to understand ur question, If i am not mistaking : you can try this :

"SELECT COUNT(*) FROM table_name";

shushant Developer · 207 posts #3

its better to count any single column then distinct SELECT COUNT(id) FROM table_name

amitdas333 Junior · 23 posts #4

razzbee wrote: I am sorry but I dont seem to understand ur question, If i am not mistaking : you can try this :

"SELECT COUNT(*) FROM table_name";

I think you had used ad4earn script, in the created ad section it shows clicks & impressions of each ad separatly. I want to add all the clicks & impressions and show it. Hope you have understand. BTW your coupon for kloudserve is not working.

s3nzo Developer · 156 posts #5

amitdas333 wrote: I want to add all the clicks & impressions and show it

$query = mysql_query("SELECT column FROM table_name WHERE id = $id");
$result = mysql_num_rows($query);
if($result > 0)
{
$count = 0;
while($row = mysql_fetch_array($query))
$count += $row[0];

echo $count;
}

Modify it how you want

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