I have a menu, and in this menu there is an option to select posts which have a certain brand name in the database. When clicked no the brand name in the menu I want the user to be directed to the page which has posts with only that brand name in the database.
This is my button url:
<a href="brands.php?brand=ALange&Söhne">A. Lange & Söhne</a>
This is my sql call:
if($_GET){
$id1 = $_GET['id'];
$id1 = (int) $id1;
$sql = "SELECT posts.id AS postid,
category.id AS catid,
category.catname,
posts.id,
posts.cat_id,
posts.brand,
posts.auction,
posts.likes,
posts.image,
posts.title,
posts.textbody,
posts.author,
posts.postdate
FROM posts INNER JOIN category ON category.id= posts.cat_id WHERE (posts.brand ='$brand')";
//"SELECT * FROM posts WHERE id='$id1' ORDER BY postdate DESC LIMIT 1";
$query = mysqli_query($db_conx, $sql);
$statusnumrows = mysqli_num_rows($query);
//get set above for ID
}
else if(!$_GET){
$sql = "SELECT posts.id AS postid,
category.id AS catid,
category.catname,
posts.id,
posts.cat_id,
posts.brand,
posts.auction,
posts.likes,
posts.image,
posts.title,
posts.textbody,
posts.author,
posts.postdate
FROM posts INNER JOIN category ON category.id= posts.cat_id WHERE (posts.brand ='$brand') ORDER BY postdate DESC";
It doesnt seem to be working. how can I get the user to go to a list of posts with only one chosen brand. Right now it displays the two posts I have where the BRAND section is left black in the database.