1
All links have the same url but the data is different..
I’m working on a web based project that I have:
- categories of games:
- games(table with games in each category)
- description of each game(are more details)
One of the categories is called FPS.PHP, on this page there are several table games coming from the database with the fields Name, Type and Platform. What I wanted was basically to be able to click on the name of each game and open a page called DESCRIPTION.PHP where would be the details of the game that we clicked. Since there could be lots of games 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 that? 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>
Voce created a table for each category ?
– Rovann Linhalis
yes @Rovannlinhalis
– Joyana
=( complicated in, have to rethink this modeling your
– Rovann Linhalis
Thank you! I just didn’t want to go to so much trouble to make huge pages for every game..... that’s very @Rovannlinhalis
– Joyana
Just as you don’t need to make a page for each game, you don’t need a table for each category... because then you wouldn’t need a database for that. Try to open a question first for modeling your program, what you need to do, then things will flow more easily.
– Rovann Linhalis
@That’s what Leocaracciolo is all about!! How he did it!?
– Joyana
i did not understand your tables. can explain better, table such columns, table talequal taisequais columns, etccc
– user60252
I have in mysql imagine a category fps that contains games and the fields of the games in the category page are just name, type and platform. When clicking on such game the description should be name, category, type, platform, publisher, release and description.
– Joyana
simplify as follows: TABLE fps COLUMNS name, type, platform TABLE xxxxx COLUMNS xx yy ... TABLE zzz COLUMNS aaa bbb ccc
– user60252
TABLE fps COLUMNS name, category, type, platform, publisher, release and description.
– Joyana
It’s just a table?
– user60252
so same release with ç and description with ç ?
– user60252
without you and without my apologies
– Joyana
look, I know it’s already solved, but from a look at the friendly url and regular expressions with php and htaccess, Thiago Belem has a blog that helped a lot at the beginning and I wanted to do exactly what you want to do, today, with these tips, I create much better apps, you can use the URI to search the database and create a dynamic page without opening another, spending less of the connection
– flourigh
@flourigh does not necessarily use two pages, it was done so because it is in question. The two response pages can merge into one by making only one connection and one select.
– user60252
@leo-Caracciolo yes, indeed, it was just a suggestion
– flourigh
@Leocaracciolo thinks he can help me with this question ? https://answall.com/questions/216221/como-fazer-simulador-de-cliques-num-link-e-por-cada-clique-adicionar-1-centimo
– Joyana