Jump to content

Greater than Less Than - Not working... IF statements.


loren646

Recommended Posts

The mysql doesn't seem to output correctly. for some reason it seems the -1 code works. but it doesn't matter what I select. the -1 one option shows. 

 


echo "<p>".$bed."<p>";   

 

shows the correct number. so that works... 

 


 

---------------

 

if

{

[working code]....

}

 

else

{

mysql_connect("localhost","user","password");

mysql_select_db("listing"); 

 

echo "<p>".$bed."<p>"; 

 

if ($bed = "4")

  {

  $myquery = "SELECT * FROM available 

              WHERE bedroom >= '$bed'

              ORDER by price ASC";

  }

 

if ($bed =  "-1")

  { 

  $myquery = "SELECT * FROM available 

              WHERE bedroom <= '1'

              ORDER by price ASC";

  }

else if ($bed < "4" || $bed > "0")

  {

         $myquery = "SELECT * FROM available 

              WHERE bedroom = '$bed'

              ORDER by price ASC";

  }

 

[more code]

 

}

if ($bed = "4")

= is the assignment operator. It assigns the value on the right to the variable on the left.

 

If to you want to compare the values, you need to use the equal comparison operator, which is == (two equal signs).

= is the assignment operator. It assigns the value on the right to the variable on the left.

 

If to you want to compare the values, you need to use the equal comparison operator, which is == (two equal signs).

 

wow. *takes hand to forehead.*

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.