I have selecting data from MySQL table and returned data looks like:
Name Rank Vessel Type Preview
John 1 ab View
Lisa 1 cd View
Carl 2 bd View
As you see above View should be link to user's profiles depending on their Id.
For now I'm using table as you see below and this is line for View link:
<?php echo "<td> <a href='preview.php?Id='" . $Id . ">View</a></td>"; ?>
I don't know why, but It redirecting users like: www.etc.com/preview.php?Id= without provided Id.
If I'm using something like:
<?php echo "<td> <a href='preview.php?Id='" . $Id . ">View " . $Id . "</a></td>"; ?>
It returning View Id for example View 1, that's mean $Id variable is fine. Have you ideas what's wrong?
Also I want to ask you If it is correct way for redirecting? Or there is any other / better way to do that?
This is PHP:
<?php
if(isset($UserID)) {
$users = $con->prepare("
SELECT DISTINCT Id,
CONCAT(FirstName, ' ', LastName) AS FullName,
RankApplied,
VesselsType
FROM tbl
");
$users->execute();
$users->bind_result($Id, $FName, $RankApplied, $VesselsType);
} else {
echo "There is no User ID detected, try to refresh browser.";
}
?>
<table>
<tr>
<th>Name</th>
<th>Rank</th>
<th>Vessel Type</th>
<th>Preview</th>
</tr>
<?php
while ($users->fetch()) {
?>
<tr>
<td><?php echo $FName; ?></td>
<td><?php echo $RankApplied; ?></td>
<td><?php echo $VesselsType; ?></td>
<?php echo "<td> <a href='preview.php?Id='" . $Id . ">View</a></td>"; ?>
</tr>
<?php
}
?>
</table>