开发者

Wordpress Not Displaying Tables Correctly?

开发者 https://www.devze.com 2023-03-30 01:14 出处:网络
I am using a post template from within Wordpress to create a table. However the formatting is a bit messed up.

I am using a post template from within Wordpress to create a table. However the formatting is a bit messed up.

The PHP that generates the code goes in and queries a server for the user's test information for the day. It then trims down that internal report to get just the table. Note that the report does not close the </tbody> tag, so I had to use a str_replace to close that tag.

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);

}

This provides me with both code for the table (only for debugging purposes), as well as what should be the table. However, the values of the table are not actually within the table, but are shown on the line above the table.

<TABLE cellspacing=0 cellpadding=0 border=1 bordercolor=Silver>
<thead class=b>
<TR bgColor=WHITE>
<th>&nbsp;Engineer&nbsp;</th><th>&nbsp;Passed&nbsp;</th><th>&nbsp;PWWarn&nbsp;</th><th>&nbsp;Blocked&nbsp;</th><th>&nbsp;Failed&nbsp;</th><th>&nbsp;Total Run&nbsp;</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

Anyone have any suggestions as to why this might happen?

Pasting View-Page Source of the final table that was generated.

<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>


Solution was found after contacting the author of SimplePostTemplate. It seems as if wordpress will filter out bad HTML, which is exactly what it did with my table, and thus why it didn't show properly.

I was able to ask the other department to clean up their html before it got to wordpress, and thus passing the filters and solving the issue.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号