PHP/Oracle
I have a search page that queries a oracle database. The seach page has 3 fields HOUSE_NO, STREET_NAME, APT_NO. The 3rd is optional to enter. Now, when the user enters just the HOUSE_NO and STREET_NAME the results is fine. But, when the user enters the APT_NO, I get a listing of all the apartments that are listed under the HOUSE_NO and STREET_NAME, including the apartment entered in the APT_NO field. Here is my code can someone help!
I need a way for the code to take in the values for the 3 fields and use a conditon statement to fire of teh correct sql. A sql statement with the APT_NO and one without.
//Connection statement
require_once('../../Connections/oracle2.php');
// begin Recordset
$colnamersdogs = '1';
if (isset($HTTP_GET_VARS['STREET_NAME'])) {
$colnamersdogs = $HTTP_GET_VARS['STREET_NAME'];
}
$NUMBERrsdogs = '1';
if (isset($HTTP_GET_VARS['HOUSE_NO'])) {
$NUMBERrsdogs = $HTTP_GET_VARS['HOUSE_NO'];
}
$APTrsdogs = 'z';
if (isset($HTTP_GET_VARS['APT_NO'])) {
$APTrsdogs = $HTTP_GET_VARS['APT_NO'];
}
if ($APTrsdogs = 'z') {
$query_rsdogs = sprintf("SELECT FROM DOG_HEADER WHERE STREET_NAME = '%s' AND HOUSE_NO = '%s'", $colnamersdogs,$NUMBERrsdogs,$APTrsdogs);
}
else {
$query_rsdogs = sprintf("SELECT FROM DOG_HEADER WHERE STREET_NAME = '%s' AND HOUSE_NO = '%s' AND APT_NO = '%s'", $colnamersdogs,$NUMBERrsdogs,$APT__rsdogs);
}
$rsdogs = $oracle2->SelectLimit($query_rsdogs) or die($oracle2->ErrorMsg());
$totalRows_rsdogs = $rsdogs->RecordCount();
// end Recordset