Обновленный ответ, работающий над Swift 3
extension String {
init?(htmlEncodedString: String) {
let encodedData = htmlEncodedString.data(using: String.Encoding.utf8)!
let attributedOptions = [ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType]
guard let attributedString = try? NSAttributedString(data: encodedData, options: attributedOptions, documentAttributes: nil) else {
return nil
}
self.init(attributedString.string)
}
<table>
<tr>
<th>Id</th>
<th>Name</th>
<th>Serial</th>
</tr>
<?php
$servername = "localhost";
$username = "";
$password = "";
$dbname = "verify";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$result = $conn->query($sql);
$stack = array();
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
array_push($stack, $row);
if(!$array) {
return $row;
}
}
}
$conn->close();
foreach($stack as $item)
{
echo "<tr><td>" . $row['ProductId'] . "</td><td>" . $row['Name'] . "</td>. <td>" . $row['SerialId'] . "</td></tr>";
}
?>
<?php
$table='<table>
<tr>
<th>Id</th>
<th>Name</th>
<th>Serial</th>
</tr>';
$servername = "localhost";
$username = "";
$password = "";
$dbname = "verify";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$result = $conn->query($sql);
$stack = array();
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
array_push($stack, $row);
if(!$array) {
return $row;
}
}
}
$conn->close();
$table_content='';
foreach($stack as $item)
{
$table_content.= "<tr>
<td>" . $row['ProductId'] . "</td>
<td>" . $row['Name'] . " </td>.
<td>" . $row['SerialId'] . "</td>
</tr>";
}
echo $table.$table_content.'</table>';
?>