admin管理员组文章数量:1322522
I would like to know how to extract data from Wordpress, unserialize and show it in a table. Below is my starting point. The columns address, group and divider all have serialize data in.
I have read about get_user_meta() but not sure how to use it.
Any suggestion welcome.
[insert_php]
//connection details
require_once('/home/xxx/private/xxx.php');
$query = "SELECT MAX(CASE WHEN wp_usermeta.meta_key = 'first_name' then wp_usermeta.meta_value ELSE NULL END) as first_name,
MAX(CASE WHEN wp_usermeta.meta_key = 'last_name' then wp_usermeta.meta_value ELSE NULL END) as last_name,
MAX(CASE WHEN wp_usermeta.meta_key = 'pm_field_13' then wp_usermeta.meta_value ELSE NULL END) as address,
MAX(CASE WHEN wp_usermeta.meta_key = 'pm_field_101' then wp_usermeta.meta_value ELSE NULL END) as group,
MAX(CASE WHEN wp_usermeta.meta_key = 'pm_field_105' then wp_usermeta.meta_value ELSE NULL END) as divider,
wp_users.user_login
FROM wp_users
LEFT JOIN wp_usermeta
ON wp_users.ID = wp_usermeta.user_id
GROUP BY wp_users.user_login";
$filter_Result = mysqli_query($connect, $query) or die("Error: ".mysqli_error($connect));
return $filter_Result;
$num_rows = mysqli_num_rows($search_result);
<table id="indextable" style="table-layout: fixed; width: 100%;" >
<thead>
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Address</th>
<th>Group</th>
<th>Divider</th>
</thead>
</tr>
<!-- populate table from mysql database -->
<?php while($row = mysqli_fetch_array($search_result)):?>
<tr>
<td><?php echo $row['first_name'];?> </td>
<td><?php echo $row['last_name'];?></td>
<td><?php echo unserialize($row['address']); ?></td>
<td><?php echo unserialize($row['group']);?></td>
<td><?php echo unserialize($row['divider']);?></td>
</tr>
<?php endwhile;?>
</table>
[/insert_php]
本文标签: phpUsermeta data unserializeextract and display in table in Wordpress
版权声明:本文标题:php - Usermeta data unserialize, extract and display in table in Wordpress 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742112553a2421317.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论