title: PHP Mysql how to retrieve product by category
body: <p>When I enter category name manually, I'm able to get its product but when I insert a variable to  like the code, I get success but data is empty.</p>
  <p>Connection file:</p>
  <pre><code>&lt;?php
  //cnnection.php 
  $server = &quot;localhost&quot;;
  $user = &quot;root&quot;;
  $password = &quot;&quot;;
  $db = &quot;db_ecommerce_shoes&quot;;
  
  $connect = new mysqli($server,$user,$password,$db);
  </code></pre>
  <p>Main script:</p>
  <pre><code>&lt;?php
      include '../connection.php';
  </code></pre>
  <p>With this, request is successful but data is empty</p>
  <pre><code>    $name= 'name';
      $sql = &quot;SELECT * FROM tb_shoes
              WHERE
              catName ='$name'        
              &quot;;
  </code></pre>
  <p>With this, request is successful, data is loaded successful</p>
  <pre><code>    $sql = &quot;SELECT * FROM tb_shoes
              WHERE
              catName ='Ladies Shoe'        
              &quot;;
      
      $result = $connect-&gt;query($sql);
      
      if($result) {    
          $data = array();
          while($row = $result-&gt;fetch_assoc()) {
              $data[] = $row;
          }
          echo json_encode(array(
              &quot;success&quot;=&gt;true,
              &quot;data&quot;=&gt; $data,
          ));
      } else {
          echo json_encode(array(
              &quot;success&quot;=&gt;false,
          ));
      }
  </code></pre>
  <p>Any other way of doing this will be much appreciated.</p>