URL parameter with 2 vaiables
I have a simple recordset that displays records from a url posted to it.
The record set only looks at one field in a table but I want to be able to send 2 variables to this record set ie send variable1 and variable2 in a url. I then need the record set to show all entries in the table that match either variable1 or variable2.
Currently it looks like this
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$colname_company_list = "-1";
if (isset($_GET['region'])) {
$colname_company_list = (get_magic_quotes_gpc()) ? $_GET['region'] : addslashes($_GET['region']);
}
mysql_select_db($database_brighton, $brighton);
$query_company_list = sprintf("SELECT * FROM directory WHERE region = %s ORDER BY listing_type ASC, business_name ASC", GetSQLValueString($colname_company_list, "text"));
$company_list = mysql_query($query_company_list, $brighton) or die(mysql_error());
$row_company_list = mysql_fetch_assoc($company_list);
$totalRows_company_list = mysql_num_rows($company_list);
mysql_select_db($database_brighton, $brighton);
$query_region = "SELECT * FROM regions ORDER BY region ASC";
$region = mysql_query($query_region, $brighton) or die(mysql_error());
$row_region = mysql_fetch_assoc($region);
$totalRows_region = mysql_num_rows($region);
?>