我想显示从两个表生成的列表。我有一个带有快捷码的页面,可以按照我的要求加载信息。短代码运行一个名为member_list
. 在这个函数中,我有一个表单,其中有一篇帖子,在提交表单时运行相同的函数。我检查哪个操作正在调用函数并添加<?php get_header(); ?>
和<?php get_footer();
当从岗位上跑开时。我的问题是,这篇文章的结果页面失去了格式,并抛出了其中四条消息
Notice: Trying to get property of non-object in D:\\www.foo.com\\wp-includes\\admin-bar.php on line 6.
我没有做什么。这是我的职责。
function member_directory($sort_order, $first_time) {
global $wpdb;
if (!$first_time){
get_header();
}
if ($sort_order == 1) {
$where_clause = "LotNoSorting";
} elseif ($sort_order == 2) {
$where_clause = "last_name, first_name";
} elseif ($sort_order == 3) {
$where_clause = "recordedsubdivision, block, lotnum";
} elseif($sort_order == 4){
$where_clause = "street, housenum";
} else {
die ("Internal Error 1");
}
$sql = "SELECT subscr_id, first_name, last_name, block, housenum, lotnum, lotno, lotnosorting, recordedsubdivision, street FROM wp_swpm_members_tbl LEFT OUTER JOIN plcoa_lots ON wp_swpm_members_tbl.subscr_id = plcoa_lots.lotno WHERE block <> \'\' ORDER BY " . $where_clause ;
$query = $wpdb->get_results($sql);
if (!empty ($query) ) {
?>
<table>
<form method="post" action="http://priestlakecoa.org/wp-admin/admin-post.php">
<td >
<input type="submit" value="Lot #" name="lot">
<input type="hidden" name="action" value="member_directory">
</td>
<td >
<input type="submit" value="Name" name="name">
<input type="hidden" name="action" value="member_directory">
</td>
<td >
<input type="submit" value="Subdivision - Blk / Lot" name="subdivision">
<input type="hidden" name="action" value="member_directory">
</td>
<td >
<input type="submit" value="Address" name="address">
<input type="hidden" name="action" value="member_directory">
</td>
</form>
<?php
foreach ($query as $row) {
?>
<tr>
<td><?php echo $row->subscr_id; ?></td>
<td><?php echo $row->first_name . " " . $row->last_name; ?></td>
<td><?php echo $row->recordedsubdivision . " " . $row->block . "/" .$row->lotnum; ?></td>
<td><?php echo $row->housenum . " " . $row->street ; ?></td>
</tr>
<?php
}
if (!$first_time){
get_footer();
}
?>
</table>
<?php
} else {
echo "Nothing found";
}
}