我正在尝试使用自定义 php 代码创建一个 Wordpress 模板,该模板连接 Wordpress 数据库中的自定义表,但它显示此代码的空白页
<?php
/*
Template Name: JNTU
*/
?>
<?php
function doSomething() {
global $wpdb;
$current_user = wp_get_current_user();
if ( 0 == $current_user->ID ) {
// Not logged in.
} else {
$id = $_POST['ID'];
$add = $wpdb->prepare("SELECT SUM(tech) AS tech4 FROM (
(SELECT SUM(tm) AS tech FROM jbit WHERE id = :id)
UNION ALL
(SELECT SUM(tm) AS tech FROM hmm WHERE id = :id))t1");
$add -> execute(array(':id'=>$id));
echo " <center><table id='mytable' cellspacing='0' border=3 align=center>
<tr><TH scope='col'>Total Marks</TH> </tr><center>";
while ($row1 = $add->fetch(PDO::FETCH_ASSOC))
{
echo "<tr>";
echo "<td align=center>" . $row1['tech4']. "</td>";
echo "</tr>";
}
}
}
?>
任何想法???