jeudi 27 août 2015

PHP If Statement Logic

I am a bit stuck on an if statement on my PHP code. I know this is probably a basic question for most of you out there, but i am stuck, and i would like some assistance.

I have 2 variables $max and $ min, which i have to compare with 2 other max and mins called $valor and $minimo in order to check if they are meeting somewhere. What i basically have is a set of values like min=20 and max=30.

I want to compare those with the other max and min, and check if somewhere the values meet, like if the min of the second one is 29. I want it to enter the if statement.

Here's the statement i got right now. But it's not working, and i just can't get the logic on it. Any help?

if ($min >= $valor && $min <= $minimo || $max >= $valor && $max <= $minimo)
    {
        //Do nothing
    }
else
    {
        $queryq = "INSERT INTO precos_area (id_tecido,area_minima,area_maxima,preco) VALUES ('".$id_tipo."', '".$min."', '".$max."', '".$price."')";
        $resultsq = mysql_query($queryq) or die(mysql_error());
    }

Aucun commentaire:

Enregistrer un commentaire