Hi,
Im a newbie to PHP and SQL and wondered if someone would helpful enough to point me in the right direction?
I have a page which is currently returning data from a table fine, i've intoduced a search field which is working great on its own i've pasted the code below.... However i want to intoduce a second field which could be searched in, i would like them to work independantly of each other, i have pasted the code i doctored at the bottom, the issue is that i cannot search in the 'city' field on its own without having to fill in the 'venue_name' field ???
$colname_venue = "%";
if (isset($_POST['venue_name'])) {
$colname_venue = $_POST['venue_name'];
}
mysql_select_db($database_brsenter_BRS, $brsenter_BRS);
$query_venue = sprintf("SELECT id, venue_name, city, first_name, last_name, telephone, email1, web_url FROM VENUE WHERE venue_name LIKE %s", GetSQLValueString("%" . $colname_venue . "%", "text"));
$query_limit_venue = sprintf("%s LIMIT %d, %d", $query_venue, $startRow_venue, $maxRows_venue);
$venue = mysql_query($query_limit_venue, $brsenter_BRS) or die(mysql_error());
$row_venue = mysql_fetch_assoc($venue);
--------------------------------------------------------------------------------
$colname_venue = "%";
if (isset($_POST['city'])) {
$colname_venue = $_POST['city'];
}
$colname2_venue = "%";
if (isset($_POST['venue_name'])) {
$colname2_venue = $_POST['venue_name'];
}
mysql_select_db($database_brsenter_BRS, $brsenter_BRS);
$query_venue = sprintf("SELECT id, venue_name, city, first_name, last_name, telephone, email1, web_url FROM VENUE WHERE city LIKE %s OR venue_name LIKE %s", GetSQLValueString("%" . $colname_venue . "%", "text"),GetSQLValueString("%" . $colname2_venue . "%", "text"));
$query_limit_venue = sprintf("%s LIMIT %d, %d", $query_venue, $startRow_venue, $maxRows_venue);
$venue = mysql_query($query_limit_venue, $brsenter_BRS) or die(mysql_error());
$row_venue = mysql_fetch_assoc($venue);
Thanks