Help needed in mysql

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Help needed in mysql

    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!!

    #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";

    Comment


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

      Comment


        #4
        Originally posted by razzbee View Post
        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.

        Comment


          #5
          Originally posted by amitdas333 View Post
          I want to add all the clicks & impressions and show it
          PHP Code:
          $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
          Last edited by s3nzo; 27.06.12, 11:37.
          libra.wen.ru

          Comment


            #6
            Thanks for the hint...

            Comment

            Working...
            X