Jump to content

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


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.*

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.