Announcement

Collapse
No announcement yet.

mysql to select highest users's post count?

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

  • mysql to select highest users's post count?

    I want to find the highest user post count to aid in an average for a script I'm working on, what would the sql query for that be?

    SELECT posts from user where posts > 0 ORDER BY posts DESC LIMIT 0, 1 ?
    [ DirgoTronix.Net ] [ DirgoTronix.Net Forums ]
    Just a local Lakewood, CO community of high schoolers, college kids, and random passers-by.

  • #2
    answered my own question.
    [ DirgoTronix.Net ] [ DirgoTronix.Net Forums ]
    Just a local Lakewood, CO community of high schoolers, college kids, and random passers-by.

    Comment


    • #3
      Re: mysql to select highest users's post count?

      Code:
      SELECT posts FROM user ORDER BY posts DESC LIMIT 1
      Last edited by Chen; Thu 23rd Aug '01, 10:26am.
      Chen Avinadav
      Better to remain silent and be thought a fool than to speak out and remove all doubt.

      גם אני מאוכזב מסיקור תחרות לתור מוטור של NRG הרשת ע"י מעריב

      Comment


      • #4
        Ok next question:

        How do I code in the equivalent of this in php:

        255 = ( ( $highestpostcount / 255 ) * X )

        I need to find X to use it as a multiplier variable for the rest of the glowy color script I'm using, so that the brightest color will always be a postcount equal to the top poster's.
        [ DirgoTronix.Net ] [ DirgoTronix.Net Forums ]
        Just a local Lakewood, CO community of high schoolers, college kids, and random passers-by.

        Comment


        • #5
          I really don't understand what you are trying to do man. Can you be any more specific?
          Chen Avinadav
          Better to remain silent and be thought a fool than to speak out and remove all doubt.

          גם אני מאוכזב מסיקור תחרות לתור מוטור של NRG הרשת ע"י מעריב

          Comment


          • #6
            I'm trying to set up a multiplier so that in my glowy color script (http://www.dirgotronix.net/test/glow.phps) it will poll the database for the highest post count (which atm is 1206), the post count of the #1 top postiing user.

            like I said, I need to find X for:

            255 = ( ( $highestpostcount / 255 ) * X )
            where $highestpostcount = 1206, but will change, of course.

            Then, I use X like so:

            X is set as $colormultiplier
            for each color (r,g,b) I run the following:
            PHP Code:
                // Red
                    
            if ( $r 15 
                        { 
                        
            $r1 $glowposts 255
                        
            $r1 round($r1); 
                        
            $r1 = ( $r1 $colormultiplier ); 
                        
            $rr dechex($r1); 
                    } 
                    else 
                        { 
                        
            $rr "0" dechex($r1); 
                    } 
            where $r is the red value of the users favorite color, $glowposts is their post count. This means that people's usernames will glow brighter the more posts they have, and the top posts's glow will for example (for white) be FFFFFF as long as they are the top poster. If the top poster had 255 posts, the $colormultiplier would have to be set as 255, and go progressively lower as their post count grew.
            [ DirgoTronix.Net ] [ DirgoTronix.Net Forums ]
            Just a local Lakewood, CO community of high schoolers, college kids, and random passers-by.

            Comment


            • #7
              I think this will do it:
              PHP Code:
              $colormultiplier "65025 / $highestpostcount"
              Chen Avinadav
              Better to remain silent and be thought a fool than to speak out and remove all doubt.

              גם אני מאוכזב מסיקור תחרות לתור מוטור של NRG הרשת ע"י מעריב

              Comment


              • #8
                how did you get 65025?
                [ DirgoTronix.Net ] [ DirgoTronix.Net Forums ]
                Just a local Lakewood, CO community of high schoolers, college kids, and random passers-by.

                Comment


                • #9
                  duh
                  [ DirgoTronix.Net ] [ DirgoTronix.Net Forums ]
                  Just a local Lakewood, CO community of high schoolers, college kids, and random passers-by.

                  Comment


                  • #10
                    Ok, I'm finding that my math is all wrong here... I'm not getting things the right way. Have a look at the src:

                    http://www.dirgotronix.net/test/glow.phps
                    and the script in action:

                    http://www.dirgotronix.net/test/glow...n&glowuserid=1

                    looks like:

                    1206 = top posts
                    54 = multiplier
                    purple = fav color
                    1 = userid
                    Jason = username
                    800080 = fav color in hex
                    128 0 128 = fav color in dec
                    108 108 = adjusted color in dec
                    6c006c = adjusted color in hex
                    Jason - final output.

                    yet, at 1206 posts, mine would be much brighter than my fav color (red is 162 where my fav is 128, etc)

                    I'm lost...
                    [ DirgoTronix.Net ] [ DirgoTronix.Net Forums ]
                    Just a local Lakewood, CO community of high schoolers, college kids, and random passers-by.

                    Comment


                    • #11
                      Fixed! If you want, reload the source page and replace it. Now it works according to their post count in relation to the max post count. Wheee!
                      [ DirgoTronix.Net ] [ DirgoTronix.Net Forums ]
                      Just a local Lakewood, CO community of high schoolers, college kids, and random passers-by.

                      Comment


                      • #12
                        yknow you could always just select MAX from the table....

                        Comment

                        widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
                        Working...
                        X