donglin4636 2015-08-29 16:30
浏览 67
已采纳

PHP显示登录的用户信息,如点

I have wordpress website and I made a page that shows the users and points from database, but it shows all the users,

I want the logged in user to see his point, getting it from his row in database. I mean when the user login with my website user can see his username and points , even can see in his profile page

Note : I am " using users ultra plugin " for profile page

I will show you code for display records from database , and it`s worknig

 <?php 

  // make connecion   
   mysql_connect('localhost', 'root', '');

// Select Database
mysql_select_db ('Nourena');


$sql="SELECT sum(points) as sumpoints , name FROM wp_wp_pro_quiz_toplist group by name order by sumpoints DESC";

$records=mysql_query($sql);



?>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>الاحصائيات النهائية لمسابقة اكتوبر</title>
</head>

<body>

 <table class="wpProQuiz_toplistTable">

        <tr>
            <th style="width: 40px;">Pos.</th>
            <th style="">Name</th>
            <th style="width: 60px;">Points</th>
           <tr>
<?php 

 $i=1;

  while($wp_wp_pro_quiz_toplist=mysql_fetch_assoc($records)) {

    echo "<tr>"; 

    echo "<td>".$i++."</td>"; 

 echo "<td>".$wp_wp_pro_quiz_toplist[name]."</td>";

    echo "<td>".$wp_wp_pro_quiz_toplist[sumpoints]."</td>";

    echo "</tr>"; 


    }// End While

 ?>               


    </table>

  </body>
  </html>

and this is code for profile page after user logging in directly from ( users ultra membership plugin )

), $atts ) );

    $html = "";


    $users_list = $this->get_logged_in_user();

    $html.='<div class="uultra-miniprofile-users">

        <ul>';

    foreach ( $users_list as $user )
    {

        $user_id = $user->ID; 

        if($pic_boder_type=="rounded")
        {
           $class_avatar = "avatar";

        }

        $html .= '<li class="'.$box_border.' '.$box_shadow.' '.$display.'" style="width:'.$item_width.'" >

           <div class="prof-photo">               
               '.$this->get_user_pic( $user_id, $pic_size, $pic_type, $pic_boder_type, $pic_size_type).'            
           </div>        

            <div class="info-div"> 

             <p class="uu-direct-name"><a class="uultra-btn-profile" href="'.$this->get_user_profile_permalink( $user_id).'">
             '. $this->get_display_name($user_id).' </a> <span>'.$this->get_user_country_flag($user_id).'</span></p> ';

             if ($optional_fields_to_display!="") 
             { 

               $html .= $this->display_optional_fields( $user_id,$display_country_flag, $optional_fields_to_display);                  

              }

              $html .= '<div class="tool-div-bar"><a class="uultra-btn-profile" href="'.$this->get_user_profile_permalink( $user_id).'" '.__('See Profile','xoousers').'><i class="fa fa-eye fa-lg"></i> </a> 
              <a class="uultra-btn-profile" href="'.$xoouserultra->get_logout_url().'" title="'.__('Logout','xoousers').'"> <i class="fa fa-power-off fa-lg"></i> </a>  </div> ';

              $html .= '</div> ';

        $html .=' </li>';           

    } //end foreach

finally I want the logged in user to see his point, getting it from his row in database.

  • 写回答

1条回答 默认 最新

  • drd2551 2015-08-30 11:10
    关注

    i solved it now , just replace this code to files to users ultra membership plugin

    ), $atts ) );
    
        $html = "";
    
    
        $users_list = $this->get_logged_in_user();
    
        $html.='<div class="uultra-miniprofile-users">
    
            <ul>';
    
        foreach ( $users_list as $user )
        {
    
            $user_id = $user->ID; 
    
            if($pic_boder_type=="rounded")
            {
               $class_avatar = "avatar";
    
            }
             mysql_connect('localhost', 'root', '');
                    mysql_select_db ('Nourena');
    $sql="SELECT sum(points) as sumpoints , name FROM wp_wp_pro_quiz_toplist where user_id=".$user_id." group by name order by sumpoints DESC ";
    
    $results=mysql_query($sql);
    $records=mysql_fetch_object($results);
    
            $html .= '<li class="'.$box_border.' '.$box_shadow.' '.$display.'" style="width:'.$item_width.'" >
    
               <div class="prof-photo">               
                   '.$this->get_user_pic( $user_id, $pic_size, $pic_type, $pic_boder_type, $pic_size_type).'            
               </div>        
    
                <div class="info-div"> 
    
                 <p class="uu-direct-name"><a class="uultra-btn-profile" href="'.$this->get_user_profile_permalink( $user_id).'">'. $this->get_display_name($user_id).' </a> <span>'.$this->get_user_country_flag($user_id).'</span></p>
    
                 <p>Points: '.$records->sumpoints.'</p>
    
                  ';
    
    
    
    
                 if ($optional_fields_to_display!="") 
                 { 
    
                   $html .= $this->display_optional_fields( $user_id,$display_country_flag, $optional_fields_to_display);                  
    
                  }
    
    
                  $html .= '<div class="tool-div-bar">
    
                  <a class="uultra-btn-profile" href="'.$this->get_user_profile_permalink( $user_id).'" '.__('See Profile','xoousers').'>
                  <i class="fa fa-eye fa-lg"></i> </"'.$xoouserultra->get_logout_url().'"a> 
    
                  <a class="uultra-btn-profile" href="'.$xoouserultra->get_logout_url().'" title="'.__('Logout','xoousers').'"> <i class="fa fa-power-off fa-lg"></i> </a>  </div> ';
    
                  $html .= '</div> ';
    
            $html .=' </li>';           
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应