I've developed an PHP page that show all the itens from an MySQL table. Now I wanna show an specific item when the user click's one of the itens on this page. How do I get this specific ID an how do I configure the <a href="">
link?
UPDATING THE QUESTION:
This is the header of cars.php page (with all results):
<?
require("admin/db/connect.php");
$sql = "SELECT * FROM tb_carros";
$limite = mysql_query("$sql");
$dados = array();
while ($sql = mysql_fetch_array($limite) ) {
$dados[] = $sql;
}
?>
and the HTML:
<?php foreach ($dados as $row): ?>
<div id="containerResumo">
<a href="#"> <!-- this is the key problem -->
<div class="dadosResumo">
<?=$row['carro']?><br /><br />
Ano: <?=$row['ano']?><br /><br />
Câmbio: <?=$row['cambio']?><br /><br />
R$ <?=$row['valor']?>
</div><!-- END of dadosItem -->
</a>
</div><!-- END of containerResumo -->
<?php endforeach ?>
Now, when the user click on an item I wanna open the page carro_item.php with the data of the item loaded on it.
The reference ID from the database is id_carro
I tried many types of code but it didn't work. Even if I put the full url on the browser the data isn't load:
http://adrianomachado.com/testesClientes/carro_item.php?id_carro=1
This is the PHP of carro_item.php:
<?
require("admin/db/connect.php");
$id = (int)$_GET['id_carro'];
$sql = "SELECT * FROM tb_carros WHERE id = $id";
?>
And the HTML:
<div class="dadosItem">
R$ <?php $valor ?><br /><br />
Ano: <?php $ano ?><br /><br />
Kilometragem: <?php $km ?><br /><br />
Cor: <?php $cor ?><br /><br />
Portas: <?php $portas ?><br /><br />
Combustível: <?php $combustivel ?><br /><br />
Câmbio: <?php $cambio ?><br /><br />
Final da placa: <?php $final_placa ?><br /><br />
Carroceria: <?php $carroceria ?>
</div><!-- END of dadosItem -->
Any help?
UPDATE 02:
This is the query in carro_item:
<?
require("admin/db/connect.php");
$sql = "SELECT * FROM tb_carros";
$limite = mysql_query("$sql");
$dados = array();
while ($sql = mysql_fetch_array($limite) ) {
$dados[] = $sql;
}
?>
But, obviously it returns all the results like the cars.php page. The question is how do I filter the results to the same ID of the link that the user clicked?
I don't know how to code the $sql = "SELECT * FROM tb_carros"; line to do that.