Announcement

Collapse
No announcement yet.

Can someone help me with this simple plugin?

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

  • Can someone help me with this simple plugin?

    I am making a very simple plugin, to display on the memberlist page, how many flight hours a member has.

    I made a plugin with the following code:

    Code:
    $pilotid = $vbulletin->userinfo['userid'];
    $gettotalflights = $vbulletin->db->query_first("SELECT COUNT( IDPIREP ) as count_flights FROM pirep WHERE IDPilot = $pilotid "); 
    $totalflights = number_format($gettotalflights['count_flights']);
    When I go to the memberslist page, all pilots show the same amount of flights flown, which equals MY amount of hours. I guess the code above is using MY userid, as I am the one viewing the page and it is calling for userinfo[] which is basically the userinfo of the person viewing the page.

    How can I edit $pilotid = $vbulletin->userinfo['userid']; so that it shows each members results?

    Thanks for any help,

    ERuiz

  • #2
    Don't really recommend something like this to be done via plugin because it increase the query count dramatically (each member listed on the page gets 1 additional query).

    But in all cases, the veriable you're looking for is probably: $userinfo[userid]
    Best Regards,
    Andy Huang

    Comment


    • #3
      So, by just taking out the ' ' from the variable, changes what is being called?

      Thanks on the tip regarding queries. But to be honest, I don't know how to accomplish this via a different approach. :-(

      Comment


      • #4
        Nope; you used $vbulletin->userinfo[userid], I suggested $userinfo[userid].

        $vbulletin->userinfo, if I'm not mistaken, is the same as $bbuserinfo, which contains information about the logged in user. Where as $userinfo contains the user it is working with on that memberlistbit.
        Best Regards,
        Andy Huang

        Comment


        • #5
          Oh ok, I will give it a try. :-)

          Comment


          • #6
            I did what you said and I get this error:

            Database error in vBulletin 3.6.4:

            Invalid SQL:
            SELECT COUNT( IDPIREP ) as count_flights FROM pirep WHERE IDPilot =;

            MySQL Error : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
            Error Number : 1064
            Date : Saturday, February 17th 2007 @ 06:49:14 PM
            Script : http://www.virtualaa.com/lounge/member.php?u=11
            Referrer : http://www.virtualaa.com/index.php?o...ember.php?u=11
            IP Address : 70.105.20.103
            Username : Efrain Ruiz
            Classname : vb_database
            Here is the current php code that gives this error:

            Code:
            $pilotid = $userinfo['userid'];
            
            $gettotalflights = $vbulletin->db->query_first("SELECT COUNT( IDPIREP ) as count_flights FROM pirep WHERE IDPilot = $pilotid "); 
            $totalflights = number_format($gettotalflights['count_flights']);

            Comment


            • #7
              Hm... seems like the hook you're hooking it to doesn't have that variable defined yet. Which one are you hooking it to?
              Best Regards,
              Andy Huang

              Comment


              • #8
                to member_start

                Should I assign it to global_start?

                Comment


                • #9
                  I think you'd need to place it in memberlist_bit instead.
                  Best Regards,
                  Andy Huang

                  Comment

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