寻找一些帮助下面的代码。我认为可能存在与我组织php调用和函数调用的方式有关的问题。我是一名初学者,并试图让用户显示来自不同表格的结果,具体取决于他们点击的链接。PHP - 根据链接显示结果
我得到这个错误:
解析错误:语法错误,意外 '{' 在/home/content/c/e/l/celebrything/html/wp-content/themes/celebrything/sidebar.php在线16
任何帮助纠正这个问题将是惊人的。下面的代码:在第一if
块上
<div id="sidebar">
<div class="post">
<h2>
<font color="#333333">Most Popular Celebrities</font><br>
<font color="#333333">in last 24 hours</font>
<br>
<br>
<a href="page.php?table=today">Today</a>
<a href="page.php?table=week">Week</a>
<a href="page.php?table=month">Month</a>
<?php
if (!in_array($table, array('today', 'week', 'month')) {
return false;
}
global $wpdb;
$result = $wpdb->get_results('SELECT name, count FROM wp_celebcount_' . $table);
foreach($result as $row) {
echo '<a href="http://www.celebrything.com/?s=' .
urlencode($row->name) . '&search=Search">' . $row->name .
'</a> - ' . $row->count . ' Posts<br/>';
}
}
?>
showTable($_GET['table']);
</h2>
</div>
</div>
<div class="clear"></div>
更新的代码 ----------------
<div id="sidebar">
<div class="post">
<h2>
<font color="#333333">Most Popular Celebrities</font><br>
<font color="#333333">in last 24 hours</font>
<br>
<br>
<a href="page.php?table=today">Today</a>
<a href="page.php?table=week">Week</a>
<a href="page.php?table=month">Month</a>
<?php
if (!in_array($table, array('today', 'week', 'month'))) {
return false;
}
global $wpdb;
$result = $wpdb->get_results('SELECT name, count FROM wp_celebcount_' . $table);
foreach($result as $row) {
echo '<a href="http://www.celebrything.com/?s=' .
urlencode($row->name) . '&search=Search">' . $row->name .
'</a> - ' . $row->count . ' Posts<br/>';
}
if (!empty($_GET['table'])) {
showTable($_GET['table']);
} else { showTable('today'); }
?>
</h2>
</div>
</div>
<div class="clear"></div>
谢谢。现在得到这个错误:解析错误:语法错误,意外'}'在/home/content/c/e/l/celebrything/html/wp-content/themes/celebrything/sidebar.php在线27 我想那里必须成为我组织这一方式的一个问题。是PHP调用和showTable($ _ GET ['table']);在正确的地方? – Mike 2009-12-11 18:22:28
谢谢。现在没有错误,但没有显示结果。我已经使用我正在使用的新代码更新了我的Q.有任何想法吗? – Mike 2009-12-11 18:30:45
你需要改变if(empty to if(!empty – 2009-12-11 18:48:15