Web Analytics Made Easy -
StatCounter count rows? - CodingForum

Announcement

Collapse
No announcement yet.

count rows?

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

  • count rows?

    Okay, this is much harder then I originally thought. I'm trying to display results
    but I want it to get the row 'ref' from members and count the number of members that have the same name under ref and have 'offerscompleted' > 0

    Its pretty hard to explain. But im trying to make a referral contest. Its supposed to show the username, the number of refs that person has that has completed one offer
    Ever want to see inside of a rave? Check out RedRoll and join our community of EDM lovers and rave fanatics.

  • #2
    Please be more descriptive. I am not sure how your tables are structured, or what it is exactly that you are trying to do.

    Comment


    • #3
      It's extremely difficult to explain..

      So lets say a member Member1 signs up at my website under the ref Admin. Lets say this member1 completes an offer so now his offerscompleted > 0 now. The user Admin has just earned one referral towards the contest. How would I make it so it counts the number of members that have the same ref and 1 offer completed?
      Ever want to see inside of a rave? Check out RedRoll and join our community of EDM lovers and rave fanatics.

      Comment


      • #4
        PHP Code:
        mysql_query("UPDATE users SET offerscompleted=offerscompleted+1 WHERE ref='Admin' AND member='member1' LIMIT 1"); 
        Change it into variables to select which member gets it.

        or if you want to get the total Admins that have 1 offer point, you'd do this.

        PHP Code:
        $query mysql_query("SELECT * FROM users WHERE ref='Admin' AND offerscompleted > '0'");
        if (
        mysql_num_rows($query) == 0) {
        echo 
        'No Matches';
        }
        else {
        echo 
        'There is matches';

        Last edited by myfayt; Sep 5, 2011, 12:25 PM.
        Been a sign maker for 8 years. My business:
        American Made Signs

        Comment


        • #5
          PHP Code:
          $query mysql_query("SELECT * FROM users WHERE ref='Admin' AND offerscompleted > '0'");
          if (
          mysql_num_rows($query) == 0) {
          echo 
          'No Matches';
          }
          else {
          echo 
          'There is matches';

          Right, But that counts only the number of refs the Admin has. What about other members?
          Ever want to see inside of a rave? Check out RedRoll and join our community of EDM lovers and rave fanatics.

          Comment


          • #6
            You run the script as you needed on the page that will display the value. If you want to fetch the ref number for all the people at the same time, put that in the while loop under the query SELECT * FROM users... so

            Comment


            • #7
              You have to change it into variables for your website, like this.

              PHP Code:
              $query mysql_query("SELECT * FROM users WHERE ref='".$userrow['status']."' AND offerscompleted > '0'");
              if (
              mysql_num_rows($query) == 0) {
              echo 
              'No Matches';
              }
              else {
              echo 
              'There is matches';

              So if your main user row was $userrow, you'd have a field named ref
              and in that field would be like Member, Admin, Guest.

              That would auto load in the query and show you for that ref.
              Been a sign maker for 8 years. My business:
              American Made Signs

              Comment


              • #8
                I'm confused now. What is the
                Code:
                WHERE ref='".$userrow['status']."'
                ????
                Ever want to see inside of a rave? Check out RedRoll and join our community of EDM lovers and rave fanatics.

                Comment


                • #9
                  status would be whatever the name of the field in your database is, where Admin is under.
                  Been a sign maker for 8 years. My business:
                  American Made Signs

                  Comment


                  • #10
                    I don't think you quite understand what im trying to accomplish.
                    Ever want to see inside of a rave? Check out RedRoll and join our community of EDM lovers and rave fanatics.

                    Comment


                    • #11
                      Okay well I've done my best with the little information I had to go on. So if you'd like someone else to look at it, that's okay.
                      Been a sign maker for 8 years. My business:
                      American Made Signs

                      Comment


                      • #12
                        Originally posted by markman641 View Post
                        I don't think you quite understand what im trying to accomplish.
                        your lack of details contributes to the problem. Show a basic layout of your table and an example of the final results. It will be easier to assist you at that point.

                        Comment


                        • #13
                          Is really hard to explain.

                          I'm trying to count the number of members that have the same name under Ref.

                          So if i have 10 members, 3 have Admin under Ref and 2 of them completed an offer. Then there is a member named Animal that has 7 refs and all of them have completed an offer i want it to display that admin has 2 refs and Animal has 7.
                          Ever want to see inside of a rave? Check out RedRoll and join our community of EDM lovers and rave fanatics.

                          Comment


                          • #14
                            Are you using php in conjunction with your SQL? Could we please see the code that you have so far, maybe it will be clarified what you're trying to do that way.

                            Comment


                            • #15
                              I don't have any code so far since I have n clue how to do it. and yes im using php
                              Ever want to see inside of a rave? Check out RedRoll and join our community of EDM lovers and rave fanatics.

                              Comment

                              Working...
                              X
                              😀
                              🥰
                              🤢
                              😎
                              😡
                              👍
                              👎