I am trying to test if the txt box txt_matrl from the previous page has anything in it. It always falls into the loop even if the text box is empty? I tried isset also. Can you see an obvious mistake?

if(($POST['txt_matrl'])!= " ")
{
$mtrl = $
POST['txt_matrl'];
if ($strWhereSet == "Yes")
{
$strWHERE = $strWHERE." AND material like '".$mtrl."'";
}
else
{
$strWHERE = "Where material like '".$mtrl."'";
$strWhereSet = "Yes";
}

}

    if(!empty($_POST['txt_matrl']))
    I did a search and found an answer. Imagine that. Thanks Weedpacket.

      What do you mean with empty? You might mean that it is NULL, that it is "" or that it is just spaces in it. And you might even mean that it is set. And the different meanings of the word empty is solved in slightly different ways. The [man]empty[/man] function is probably what you want to check, but I have a few examples below.

      // To check if it is set
      if (isset($_POST['variable']))
      
      // To check if it is null
      if (is_null($_POST['variable']))
      
      // To check if it is an empty string
      if ($_POST['variable'] == "")
      
      // To check if it is set but still empty
      if (empty($_POST['variable']))
      
      // To check if it is empty or just spaces, normally this is considered as empty
      if (empty(trim($_POST['variable'])))
      
      // And last to be sure not to get an error message do the following
      if (isset($_POST['variable']) && empty(trim($_POST['variable'])))

        Thanks
        I also need help on putting the wildcard % in my like statement.
        Any ideas?

          Resolved part 2

          if(!empty($POST['txt_matrl']))
          {
          $mtrl = $
          POST['txt_matrl'];
          if ($strWhereSet == "Yes")
          {
          $strWHERE = $strWHERE." AND material like '%".$mtrl."%'";
          }
          else
          {
          $strWHERE = "Where material like '%".$mtrl."%'";
          $strWhereSet = "Yes";
          }

          }

            Write a Reply...