1
我正在使用Wordpress内的发布模板创建表格。但是格式化有点搞砸了。Wordpress无法正确显示表格?
生成代码的PHP进入并向服务器查询当天用户的测试信息。然后它细化内部报告以获取表格。请注意,报告不会关闭</tbody>
标记,所以我必须使用str_replace关闭该标记。
global $current_user;
get_currentuserinfo();
$raw_contents = file_get_contents('http://******/NamedRptRun.asp?Rpt=DailyUserSum&Prj=******_****UserId='.($current_user->user_login));
$trim_raw = trim($raw_contents);
//echo htmlentities($trim_raw);
if ($trim_raw == 'No Records Returned') {
echo 'No test cases to report today.';
} else {
$tag = '<TABLE';
$topTrim_contents = stristr($raw_contents, $tag);
$tag = '</BODY>';
$table_only = stristr($topTrim_contents, $tag, TRUE);
$table_only = str_replace("</tr></table>", "</tbody></tr></table>",$table_only);
echo htmlentities($table_only);
echo str_replace(array("\r\n","\n","\t"), ' ',$table_only);
}
这为我提供了表格的代码(仅用于调试目的)以及应该是什么表格。但是,表格的值实际上并不在表格中,但显示在表格上方的行中。
<TABLE cellspacing=0 cellpadding=0 border=1 bordercolor=Silver>
<thead class=b>
<TR bgColor=WHITE>
<th> Engineer </th><th> Passed </th><th> PWWarn </th><th> Blocked </th><th> Failed </th><th> Total Run </th></tr></thead><tbody class=h><TR bgColor=#F1F1F1><TD nowrap>myname</td><TD nowrap>1</td><TD nowrap>0</td><TD nowrap>0</td><TD >0</td><TD nowrap>1</td></tbody></tr></table>
10001
Engineer Passed PWWarn Blocked Failed Total Run
myname
任何人有任何建议,为什么会发生这种情况?
粘贴查看页面生成的最终表格的来源。
<table border="1" cellspacing="0" cellpadding="0">
<thead class="b">
<tr bgcolor="WHITE">
<th> Engineer</th>
<th> Passed</th>
<th> PWWarn</th>
<th> Blocked</th>
<th> Failed</th>
<th> Total Run</th>
</tr>
</thead>
<tbody class="h">
<tr bgcolor="#F1F1F1">
<td nowrap="nowrap">myname</td>
</tr>
</tbody>
</table>
对于初学者,您的结束''和''标记是错误的方式。另外,您使用的是哪种浏览器?可能会帮助我重现问题... –
我正在使用最新版本的Firefox和Chrome。我也运行Wordpress 3.2.1,有趣的是,它在3.1中正常工作。 –
那么,你的HTML - 甚至你的原始版本;我只是把它粘贴 - 在WordPress 3.2.1的帖子中呈现给我。也许你的主题CSS或插件或其他东西是捣毁的东西? –