Ok I got a database and I have 4 drop down select box for a user seach query, they need to be able to seach for all 4 arguments or just 1 argument or 2 or 3 , any combination of them. I have tryed a few ways of doing this but I cant get it 2 work , I have found other ways to do it but its a very long process. is there any shorter way? Here is somthing I was working on. but cant get it to work probly with the large if() statment.
| Code: |
| mysql_connect("localhost", "$user", "$pass") or die(mysql_error());
mysql_select_db("$db") or die(mysql_error()); $property_type = $_POST[property_type]; $price_range = $_POST[price_range]; $location = $_POST[location]; $number_of_room = $_POST[number_of_room]; $empty = ""; if($property_type != $empty) $argument1 = "($property_type == $row[property_type])"; if($price_range != $empty) $argument2 = "&($price_range == $row[price_range])"; if($location != $empty) $argument3 = "&($location == $row[location])"; if($number_of_room != $empty) $argument4 = "&($number_of_room == $row[number_of_room])"; $result = mysql_query("SELECT * FROM property_database") or die(mysql_error()); echo "<table id=\"table\" border=\"0\" cellpadding=\"0\" cellspacing=\"2\"><tr>\n"; // fetching from query 1 while($row = mysql_fetch_array( $result )) { if($argument1 $argument2 $argument3 $argument4) {echo " <td style=\"padding:25px; background-color:#D0DDF0;\" style=\"-moz-opacity:0.4;filter:alpha(opacity=40)\" onmouseover=\"this.style.MozOpacity=1;this.filters.alpha.opacity=100\" onmouseout=\"this.style.MozOpacity=0.4;this.filters.alpha.opacity=40\"> <a class=\"thumbnaillinks\" href=\"$row[url]\"> <img id=\"thumbnail\" src=\"$row[picture]\" border=\"0\"> <br>Price: $row[price] <br>location: $row[location] <br>No.of Bedrooms: $row[number_of_room]</a></div></td>";} else {}; }; ?> |
