Código PHP:
<content>
<?php
include('conexion.php');
$res = mysqli_query($con,"SELECT id,marca,modelo,km,precio,imagen FROM vehiculos") or die ("Error al traer registros");
while ($f = mysqli_fetch_array($res)){
?>
<a href="./detalles.php?id=<?php echo $f['id']?>" >
<article>
<div class="vehiculo">
<img src="images/<?php echo $f['imagen'];?>" alt="" />
<div class="detalles">
<h2 class="marca"><?php echo $f['marca'];?></h2>
<p class="modelo"><?php echo $f['modelo'];?></p>
<p class="km"><?php echo $f['km'];?></p>
<p class="precio"><?php echo $f['precio'];?></p>
</div>
</div>
</article>
</a>
<?php
}
?>
<?php
include('conexion.php');
// varificamos que el formulario halla sido enviado
$buscar = "";
$buscar = $_GET['buscar'];
if(isset ($buscar) && !empty($buscar)){
$res = mysqli_query($con,"SELECT * FROM vehiculos WHERE marca LIKE '%".$buscar."%'");
while($f = mysqli_fetch_array($res)){
?>
<a href="./detalles.php?id=<?php echo $f['id']?>" >
<article>
<div class="vehiculo">
<img src="images/<?php echo $f['imagen'];?>" alt="" />
<div class="detalles">
<h2 class="marca"><?php echo $f['marca'];?></h2>
<p class="modelo"><?php echo $f['modelo'];?></p>
<p class="km"><?php echo $f['km'];?></p>
<p class="precio"><?php echo $f['precio'];?></p>
</div>
</div>
</article>
</a>
<?php
}
}else{
echo "No se han encontrado registros";
}
?>