最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

php - how to get data from two different table from wordpress database

programmeradmin5浏览0评论

I have two different table in wordpress one is custom table and another is wp_usermeta table.

one email is matched from both table so i want to get data from both table using email address is matched. My query is:

$sql = "SELECT * FROM wp_usermeta,tbl_information 
WHERE   wp_usermeta.meta_value = 
tbl_information.account_email AND 
((wp_usermeta.meta_key = 'mycv') OR (wp_usermeta.meta_key = 'drivinglicence') OR 
(wp_usermeta.meta_key = 'first_name') OR (wp_usermeta.meta_key = 'last_name') OR 
(wp_usermeta.meta_key = 'address') OR (wp_usermeta.meta_key = 'nickname'))"

$infos = $wpdb->get_results($sql);

foreach ($infos as $u) {
      $users[$a->user_id][$a->meta_key] = $a->meta_value;
}
foreach ($users as $u) {
   <?php echo $u['first_name'].' '.$u['last_name'];?>
}

This is works but when i try to print tbl_information table data like one of the field is: account_name

So i try to print like <?php echo $u['account_name'];?>

But it wont work.

发布评论

评论列表(0)

  1. 暂无评论