Search code examples
phppostboolean-logicisset

Multiple isset queries in one if loop


I'm trying to get the following query:
If exists value of A and value of B OR if there is a value of A OR if there is a value of B ----> DO SOMETHING

if((isset($_POST['A'], $_POST['B'])) OR !empty($_POST['B']) OR !empty($_POST['A']))
    {
        echo "there is something:" . $_POST['B'] . ", " . $_POST['A'];
    }
    else
    {
        echo "its empty<br />";
    }

When in one of the fields is a value works correctly, but when we have empty both fields is still apparent that something exists.

Is wine may lie with autocomplete?

$checkVIN1 = mysql_query("SELECT vhl_vin FROM vhldescription");
$num_rows = mysql_num_rows($checkVIN1);
$i = 0;
echo "<script>$(function() {var availableTags = [";
while($checkVIN2 = mysql_fetch_array($checkVIN1, MYSQL_ASSOC))  {   $i++;   echo "\"" . <br />$checkVIN2['vhl_vin'] . "\",";
    if ($i == ($num_rows))  {   echo "\"" . $checkVIN2['vhl_vin'] . "\"";   }   }
echo "];$( \"#tags\" ).autocomplete({source: availableTags});});</script>";
<input id="tags" name="A" class="le-input">

Solution

  • How about this?

    <?php
    $a;
    $b;
    
    
    if((isset($a) or isset($b)) and !(empty($a) or empty($b))){
        echo "do something";    
    }else{
        echo "do nothing";
    }