Hello please someone can help me with this code? I think there i can remove * and GET id.
<div class="col-md-4"> <h1>Sidebar</h1> <?php require_once 'connessione.php'; $id=$_GET['id']; $query = "SELECT * FROM campi_name where id='$id'"; $stmt = $DBcon->prepare( $query ); $stmt->execute(); while($row=$stmt->fetch(PDO::FETCH_ASSOC)){ ?> <div class="media"> <div class="media-left"> <a href="#"> <img class="media-object" src="..." alt="..."> </a> </div> </div> <?php } ?> </div> How can i show only item (from db) related to the Brand row from table campi_name?
and with code like that how i can show 5 random item from campi_name?
Thank you!
SELECT * FROM campi_name ORDER BY RAND() LIMIT 5fetch();is used to fetch a single result, use fetchall() instead : stackoverflow.com/questions/14075954/pdo-fetch-fetchallJOINyour data