loren646 Posted March 15, 2013 Share Posted March 15, 2013 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] } Link to comment https://forums.phpfreaks.com/topic/275685-greater-than-less-than-not-working-if-statements/ Share on other sites More sharing options...
kicken Posted March 15, 2013 Share Posted March 15, 2013 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). Link to comment https://forums.phpfreaks.com/topic/275685-greater-than-less-than-not-working-if-statements/#findComment-1418765 Share on other sites More sharing options...
loren646 Posted March 15, 2013 Author Share Posted March 15, 2013 = 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.* Link to comment https://forums.phpfreaks.com/topic/275685-greater-than-less-than-not-working-if-statements/#findComment-1418819 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.