2017-04-26 11 views
2

私はwordpressのテーブルとしてユーザデータベースを表示するように取り組んでいます。 get_results()を使用して、私は希望の出力も得ています。しかし、引数を渡すことでこれに対する回避策があります。ここに私の仕事です:PHPでのget_resultsの可能な回避策はありますか?

<?php 
get_header(); ?> 

<?php 

global $wpdb; 
$table_name = $wpdb->prefix .'users'; 
$row = $wpdb->get_results("select*from $table_name"); 

echo "<h2><center><u>List Of Members</u></center></h2>"; 
echo "<table class='table'>"; 
echo "<thead> 
     <tr> 


     <th><center>Member Name</center></th> 
     <th><center>Age</center></th> 
     <th><center>Class</center></th> 
     <th><center>Address</center></th> 
     </tr> 
     <thead>"; 

foreach ($row as $row) 

    { 

    $usid = $row->ID; 
    $username = $row->user_login; 

    echo "<tr><td>".$username."</td>"; 
    $age=get_user_meta($usid, 'age', true); 
    echo "<td>".$age."</td>"; 
    $class=get_user_meta($usid, 'class', true); 
    echo "<td>".$class."</td>"; 
    $address=get_user_meta($usid, 'address', true); 
    echo "<td>".$address."</td>"; 
    } 
?> 

答えて

1

はいあります。 get_usersを使用してくださいこの記事はあなたを助けますhttps://codex.wordpress.org/Function_Reference/get_users

+0

<?php グローバル$ wpdb; $ table_name = $ wpdb->接頭辞 'ユーザー'; $ argsを=配列( 'ID' => $ USID、 \t \t \t 'USER_LOGIN' => $ユーザ名、 \t \t \t 'meta_key' => 'アドレス'、 \t \t \t 'meta_value' => $アドレス); $ row = $ wpdb-> get_users($ args); foreachの – Jackson

+1

GET_USERSが$ wpdbなしで実行する必要がある($行として$行) 今エラーが起こっている未定義の方法GET_USERS()。 –

関連する問題