4
while ($row = mysqli_fetch_array($result)) {
echo "<li class='list-inline-item'><a href='news.php?id=" .$row['id']. "'>". $row['titulo'] ."</a></li>";
echo "<br>";
}
I have this little code that searches the bank for all existing news titles. As you can see, I also added a link to each one. But I would like to know how to treat each of the ids on a following page, when the user click on the linked title open a page with more information.
-
<?php
include("config.php");
if(isset($_GET["id"]))
{
$id = $_GET['id'];
$listagem = "SELECT * FROM noticia WHERE id = $id";
$result = mysqli_query($conexao, $listagem);
$linha = mysqli_fetch_assoc($result);
echo $linha['titulo'];
echo "<br>";
echo $linha['news'];
}
?>
In the archive
news.php
, you can recover the value ofid
using$_GET["id"]
. This is the question?– Woss
Basically yes. I’m still trying to imagine how it would be done, but thanks! I’ll try to look for some examples here.
– SkullFire
To select the other registration information, just do the
select
in the database returning the record that has theid
equal to$_GET["id"]
– Woss
If a file already exists
news.php
, make aprint_r($_GET['id'])
on it. So when you click on the link, thisid
will be printed on the body ofnews.php
. Once you’ve done that, you can just make oneSELECT titulo, conteudo FROM noticias WHERE id = {$_GET[
id]}
and print the result of the consultation, all of this innews.php
. There must already be related questions here.– Edilson