doushuhuai7247 2016-08-06 23:15
浏览 8
已采纳

为什么PHP在我的表中插入反引号?

I am confounded by this behavior. Here is the output:

enter image description here

PHP table creation:

$table = '<div class="table-responsive"><table class="table table-stripped">
        <thead>
        <tr>
            <th>Name</th>
            <th>Title</th>
            <th>Work Type</th>
            <th>Genre</th>
            <th>PDF</th>
            <th class="fa fa-envelope-o" style="font-size: larger; color: blue;" title="Send Writer Email"></th>
            <th class="fa fa-thumbs-o-up" style="font-size: larger; color: green;"  title="Request Manuscript"></th>
            <th>Rating</th>
        </tr></thead><tbody>';
foreach ($rows as $row) {
    $table .= "<tr class='trow'>
        <td class='fullname'>" . $row['Name'] . "</td>
        <td class='title'>" . $row['Title'] . "</td>
        <td class='form-type'>" . $row['FormType'] . "</td>
        <td class='genre'>" . $row['Genre'] . "</td>
        <td><a class='synopsis' href='uploads/" . $row['Filename'] . "' target='_blank'>synposis</a></td>
        <td><input type='checkbox' class='sendemail' /></td>`
        <td><input type='checkbox' class='email-request-manuscript' /></td>
        <td><div class='rating'></div></td>
        <td class='hidden email'>" . $row['Email'] . "</td>
        <td class='hidden id'>" . $row['ID'] . "</td>
        <td><input class='hidden writer-rating' value='" . $row['Rating'] . "'/></td>
        </tr>";
};
$table .= "</tbody></table></div>";
echo $table;

JS (retrieves table from PHP)

$('#table-list').empty().append(table);
console.log($('#table-list').html());

console.log (one table row)

<div class="table-responsive">`
                `
                `
                `
                `
                `
                `
                `
                <table class="table table-stripped">
                <thead>
                <tr>
                    <th>Name</th>
                    <th>Title</th>
                    <th>Work Type</th>
                    <th>Genre</th>
                    <th>PDF</th>
                    <th class="fa fa-envelope-o" style="font-size: larger; color: blue;" title="Send Writer Email"></th>
                    <th class="fa fa-thumbs-o-up" style="font-size: larger; color: green;" title="Request Manuscript"></th>
                    <th>Rating</th>
                </tr></thead><tbody><tr class="trow">
                <td class="fullname">Ron Tornambe</td>
                <td class="title">The Hunting of the Snark</td>
                <td class="form-type">Short Story</td>
                <td class="genre">Absurdist/surreal/whimsical</td>
                <td><a class="synopsis" href="uploads/3752805599.pdf" target="_blank">synposis</a></td>
                <td><input type="checkbox" class="sendemail"></td><td><input type="checkbox" class="email-request-manuscript"></td>
                <td><div class="rating"></div></td>
                <td class="hidden email">ron.tornambe@bunkerhill.com</td>
                <td class="hidden id">101</td>
                <td><input class="hidden writer-rating" value="3"></td>

How can this happen?

  • 写回答

1条回答 默认 最新

  • duanjun7801 2016-08-06 23:20
    关注

    You have in your code this:

    <td><input type='checkbox' class='sendemail' /></td>`
    

    There at the end is backtick, which propagates to output. Delete it.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!