ron tornambe ron tornambe - 4 months ago 15
PHP Question

Why is PHP inserting backticks into my table?

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?

Answer

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.