You need to use the AND or OR in between each thing you are searching for in the query string. Also you really need to add some security measures cause right now it's wide open to sql injection attacks. Here are 2 examples depending on what you are after for a result.
PHP Code:
// This example says that it will only return info if all 3 vars match a row in the db.
$area = mysql_real_escape_string($_GET['area']);
$structure number = mysql_real_excape_string($_GET['structure_number']); // Use this if it's NOT a full integer value.
$structure number = (int)$_GET['structure_number']; // Use this if it IS a full integer value.
$block_number = mysql_real_escape_string($_GET['block_number']); // Use this if it's NOT a full integer value.
$block_number = (int)$_GET['block_number']; // Use this if it IS a full integer value.
$q1 = "SELECT * FROM `platform_locations` WHERE `area` = '$area' AND `structure_number` = `$structure_number' AND `block_number` = '$block_number'";
$r1 = mysql_query($q1) or die(mysql_error());
$a1 = mysql_fetch_array($r1);
PHP Code:
// This example says that if any of the 3 vars are equal to a column in the db it will return the info.
$area = mysql_real_escape_string($_GET['area']);
$structure number = mysql_real_excape_string($_GET['structure_number']); // Use this if it's NOT a full integer value.
$structure number = (int)$_GET['structure_number']; // Use this if it IS a full integer value.
$block_number = mysql_real_escape_string($_GET['block_number']); // Use this if it's NOT a full integer value.
$block_number = (int)$_GET['block_number']; // Use this if it IS a full integer value.
$q1 = "SELECT * FROM `platform_locations` WHERE `area` = '$area' OR `structure_number` = `$structure_number' OR `block_number` = '$block_number'";
$r1 = mysql_query($q1) or die(mysql_error());
$a1 = mysql_fetch_array($r1);
Notice the use of `backticks` around the table and column names. Try to get into the practice of using those. It makes mysql understand that those are definitely table and column names, just in case you accidentally try to use a mysql reserved keyword it won't be an issue then.
Also if any of the vars are integer values, you don't truly need to use 'single' quotes around them in the query string, since the quotes are only needed for string values. It doesn't really hurt to use them unless you are trying to compare the TYPE of value in the db.
Bookmarks