Hello.
I have while
which prints on the screen a list of all the company names in my database:
$sql = "SELECT 'nomep' FROM 'cadastropn' WHERE 'cidade' = '$cidade'";
$result = mysqli_query($mysqli, $sql);
while($linha = $result->fetch_assoc()) {
echo '<div id="lista"><img src="_imagens/pizzaiolo_corpo-300x288.png" class="logo"><a href="javascript:mostrar();"><h2>'.$linha['nomep'].'</h2></a></div>';
Each record of this list, when clicked, causes this article to be shown:
<article class="detalhes">
<?php
$sql = "SELECT 'nomep', 'descricao', 'funciona','googlemaps', 'telefone', 'cidade', 'bairro', 'endereco', 'site', 'email', 'facebook', 'googleplus' FROM 'cadastropn' WHERE 'cidade' = '$cidade' && 'id' = '1'";
$result = mysqli_query($mysqli, $sql);
while($linha = $result->fetch_assoc()) { (...)
My question is that this list always shows the result of the same item even when I click on others (which is why I indicated the above id) Now how to do the following: I clicked on the first item of the list and in the article details will appear the record of id = '1'
. Then I clicked on the second item in the list and in the article details will appear the record of id = '2'
, so on.