Hi, so this is the most basic thing ever but i am having trouble with it. idk if its because of the code or it just can't be done or idk something. I am trying to retrieve from database by clicking on a [input type submit] button but I am getting Fatal Error near my WHERE syntax.

<input type="submit" name="bf" class="btn btn-default filter-button" value="Bowls & Feeders">

<?php
   if(isset($_GET['bf'])){
      $cat = "Bowls & Feeders";

      $query = $conn->prepare("SELECT * FROM table WHERE type = ':type");
      $query->bindParam(':type', $cat, PDO::PARAM_STR);
      $query->execute();
      $result = $query->fetch(PDO::FETCH_ASSOC);              
    }
?>

I have stared at the code for awhile that i might go blind. please help. thank you in advance.

Well, it was a missing apostrophe(?) i that what you call this ' ? but now its just blank.

You dont do anything with the result so of course it is blank.

Use of & inside REQUEST variable is not good idea. I suggest replace to and but if you realy want to use it then use as &amp;

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.