All links have the same url but the data is different.
I'm working on a web based project where I have:
- game categories:
- games (table with games in each category)
- description of each game (more details)
One of the categories is called FPS.PHP, on this page there are several table games coming from the database with the Name, Type and Platform fields. What I wanted was basically able to click on the name of each game and open a page called DESCRIPTION.PHP where the details of the game that we clicked would be. Since games can be huge and making a page for each game would be exhausting, I wanted to be able to make a page that would serve as a description page for everyone.
PS: Each category has a table in the mysql database that contains games.
Does anyone know how to do this? FPS.PHP (First)
<?php
$servername = "localhost";
$username = "root";
$password = "Estagiarios2017#";
$dbname = "ricardo";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT name, tipo, plataforma FROM fps";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
echo "<table><tr><th>Name </th><th>Type </th><th>Platform </th></tr>";
// output data of each row
while($row = $result->fetch_assoc()) {
echo "<tr><td><a href='description.php?idfps=".$row['name']."'</a>" . $row["name"]. "</td><td>" . $row["tipo"]. " </td><td>" . $row["plataforma"]. "</td></tr>";
}
echo "</table>";
} else {
echo "0 results";
}
?>
FPS.php EDITED
<tr>
<td valign="top">
<div class="feed_title" ><?php echo $fps["name"]; ?></div>
<div id="fps-<?php echo $fps["idfps"]; ?>">
<input type="hidden" name="rating" id="rating" value="<?php echo $fps["rating"]; ?>" />
<ul onMouseOut="resetRating(<?php echo $fps["idfps"]; ?>);">
<?php
for($i=1;$i<=5;$i++) {
$selected = "";
if(!empty($fps["rating"]) && $i<=$fps["rating"]) {
$selected = "selected";
}
?>
<li class='<?php echo $selected; ?>' onmouseover="highlightStar(this,<?php echo $fps["idfps"]; ?>);" onmouseout="removeHighlight(<?php echo $fps["idfps"]; ?>);" onClick="addRating(this,<?php echo $fps["idfps"]; ?>);">★</li>
<?php } ?>
<ul>
</div>
<div><?php echo $fps["descricao"]; ?></div>
<?php echo"<a href='description.php?idfps=".$row['name']."'>Ver mais</a>"?>
</td>
</tr>