title: if isset empty and if not empty in PHP?
body: <p>I'm trying to check to see if <code>isset is empty</code> and if it is then I would like to do something else.</p>
  
  <p>I have a few checkboxes in my form and <code>ONE input field (hidden field and its name is keyword2)</code>. if the users check any of the checkboxes and submit the form, they will be presented with the requested information from mysql database. this works fine and as it should.</p>
  
  <p>on the page load, none of the checkboxes is checked BUT the input field always will have a value in it and it will never be empty.</p>
  
  <p>So, I am trying to load some Other data/information on page load if the users submit the Form without checking any checkbox!</p>
  
  <p>This is what I have done so far:</p>
  
  <pre><code>&lt;?php
  $searchList = "";
  $clause = " WHERE ";//Initial clause
  $sql="SELECT *
  FROM `yt`
  INNER JOIN `ATTRIBUTES` ON yt.id=ATTRIBUTES.id";//Query stub
      if(isset($_POST['keyword']) &amp;&amp; !empty($_POST['keyword'])){
  
          foreach($_POST['keyword'] as $c){
              if(!empty($c)){
                  $keyword2 = $_POST['keyword2'];
                  ##NOPE##$sql .= $clause."`".$c."` LIKE '%{$c}%'";
                  $sql .= $clause . " (ATTRIBUTES.sizes LIKE BINARY '$c' OR ATTRIBUTES.colors LIKE BINARY '$c') AND ATTRIBUTES.type='$keyword2'";
                  $clause = " OR ";//Change  to OR after 1st WHERE
              }
          }
          $sql .= " GROUP BY yt.id";
          $query = mysqli_query($db_conx, $sql);
              $productCount = mysqli_num_rows($query);
              if ($productCount &gt; 0) {
                  while($row = mysqli_fetch_array($query, MYSQLI_ASSOC)){
               $id = $row["id"];
               $product_name = $row["product_name"];
                     $searchList .= '&lt;a class="overlay" href="product.php?id='.$id.'"&gt;&lt;/a&gt;';
                  }
              }
          }
  
          ///////////////IF EMPTY////////////////
  if(isset($_POST['keyword']) &amp;&amp; empty($_POST['keyword'])){
     $keyword2 = $_POST['keyword2'];
     $sql = "SELECT * FROM ATTRIBUTES WHERE type='$keyword2'";
     $query = mysqli_query($db_conx, $sql);
     $productCount = mysqli_num_rows($query );
              $productCount = mysqli_num_rows($query);
              if ($productCount &gt; 0) {
                  while($row = mysqli_fetch_array($query, MYSQLI_ASSOC)){
               $id = $row["id"];
               $product_name = $row["product_name"];
                     $searchList .= '&lt;a class="overlay" href="product.php?id='.$id.'"&gt;&lt;/a&gt;';
                  }
              }
          }
  ?&gt;
  </code></pre>
  
  <p>As you can see in the code above, I first check if the checkboxes ($keyword) is not empty and if not empty, I will do something and this works fine.</p>
  
  <p>and in the second part of the code, I am checking to see if IT IS EMPTY and if it is then I want to do something else but this doesn't really work and as if it is not checking for it being empty and I will not get any result after I submit the form.</p>
  
  <p>I hope I explained it properly so someone can help me.</p>
  
  <p>any help would be appreciated.</p>
  
  <p>Thank in advance.</p>