This is part of a small project that im working, in this page I getting info from a database, my question(problem) is why this line of code works.
echo '<td><a href="add.php?id=' .$row['id'] .'">' . htmlentities($row['name'], ENT_QUOTES, 'UTF-8') . '</a></td>';
But this one don't work
<td><?php ' ' . htmlentities($row['name'], ENT_QUOTES, 'UTF-8') . ' ' ?> </td>
This is the entire code of the page
<?php
require("coneccion.php");
$id = $_GET['id'];
$_SESSION['id'] = $id;
$query = "SELECT id, name, due, points FROM grades WHERE id = '$id' ";
try
{
$stmt = $db->prepare($query);
$stmt->execute();
}
catch(PDOException $ex)
{
die("Error 1" . $ex->getMessage() );
}
$rows = $stmt->fetchAll();
?>
<br />
<a href="add.php">Add</a>
<table border="1">
<tr>
<th>Name</th>
<th>Due</th>
<th>Points</th>
</tr>
<?php foreach($rows as $row):
echo "<tr>";
echo '<td><a href="add.php?id=' .$row['id'] .'">' . htmlentities($row['name'], ENT_QUOTES, 'UTF-8') . '</a></td>';
?>
<td><?php ' ' . htmlentities($row['name'], ENT_QUOTES, 'UTF-8') . ' ' ?> </td>
</tr>
<?php
endforeach;