DwZone Forum DwZone Forum
Welcome to the DwZone-it Forum
 
  FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups  
    RegisterRegister -->   LoginLogin  
Advanced Search  
DwZone Forum Index -> Advanced Search

Moderators: AdministratorsModerators 
Hint: For improved responsiveness, use Internet Explorer 4 (or above) with Javascript enabled, choose 'Dynamic' from the View dropdown and hit 'Set Options' to save your changes.
New Topic Search for
 View     Per page     Messages Since 
Messages 41 to 50 of 282 (Total: 122) First |  Prev |  Next |  Last  
 Subject Author Date  
    Re: advance search results page  
View this persons public profile  JohnMerlino   21:25 12 Dec 2011  
 
OK I have tried time and time again to make this script work for me and my situation but it is not working. Furthermore the documentation is brief and incomplete. Also this forum does not allow any way to attach a file for viewing so I have pasted code here.

I have six variables I want to search which I have created a form for. Even explaining what I have had to create to do this is confusing. My variables are in a DB table called BF_comments. The ones I want to be able to search are ( lName, serverName, location, foodComment, ServerComment, a date range )

Here is the code for the form: I am just confused on how to make this all work. The widget does not even work correctly allowing me to not be able to select the form field I need to run the term search

<?php
//*****************
// Advanced Search
//*****************
require_once("../dwzSearch/dwzSearch.php");
?>
<?php require_once('../Connections/BFCONN.php'); ?>
<?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;
}
}

mysql_select_db($database_BFCONN, $BFCONN);
$query_Recordset1 = "SELECT DISTINCT BF_comments.lName FROM BF_comments";
$Recordset1 = mysql_query($query_Recordset1, $BFCONN) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);

mysql_select_db($database_BFCONN, $BFCONN);
$query_Recordset2 = "SELECT DISTINCT BF_comments.serverName FROM BF_comments";
$Recordset2 = mysql_query($query_Recordset2, $BFCONN) or die(mysql_error());
$row_Recordset2 = mysql_fetch_assoc($Recordset2);
$totalRows_Recordset2 = mysql_num_rows($Recordset2);

mysql_select_db($database_BFCONN, $BFCONN);
$query_Recordset3 = "SELECT * FROM BF_comments";
$Recordset3 = mysql_query($query_Recordset3, $BFCONN) or die(mysql_error());
$row_Recordset3 = mysql_fetch_assoc($Recordset3);
$totalRows_Recordset3 = mysql_num_rows($Recordset3);


?>
<?php
//**************************
// Advanced Search
// http://www.DwZone-it.com
// Version: 1.0.2
//**************************
$dwzSearch_1 = new dwzSearch();
$dwzSearch_1->Init();
$dwzSearch_1->SetFormName("searchComments");
$dwzSearch_1->SetSubmitName("search");
$dwzSearch_1->AddFilter("", "Between", "updated", "startDate", "endDate", "S", "0");
$dwzSearch_1->AddFilter("", "=", "serverName", "serverName", "", "S", "0");
$dwzSearch_1->AddFilter("", "Like", "serverComment", "serverComment", "", "S", "0");
$dwzSearch_1->AddFilter("", "Like", "foodComment", "foodComment", "", "S", "0");
$dwzSearch_1->AddFilter("", "Like", "lName", "lName", "", "S", "0");
$dwzSearch_1->AddFilter("", "=", "location", "location", "", "S", "0");
$dwzSearch_1->SetRecordset($Recordset3, "Recordset3");
$dwzSearch_1->SetSql($query_Recordset3);
$dwzSearch_1->SetConnection($hostname_BFCONN, $database_BFCONN, $username_BFCONN, $password_BFCONN);
$dwzSearch_1->Create();
if($dwzSearch_1->HasFilter()){
$dwzSearch_1->FilterRecordset();
}
//**************************
// Advanced Search
// End code
//**************************
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Search Comments</title>

<script language="javascript" src="js/cal2.js"></script>
<script language="javascript" src="js/cal_conf2.js"></script>
</head>

<body><form id="searchComments" name="searchComments" method="post" action="newSearch.php">
<table width="100%" border="0" cellspacing="4" cellpadding="4">
<tr>
<td width="38%" align="right">Date Range:</td>
<td width="62%">Start Date:<input type="text" name="startDate" size=20 id="startDate" tabindex="5">
<small><a href="javascript:showCal('startDate')"><img src="../images/Calendar-48.png" alt="Click for Calendar" width="23" height="23" border="0"></a></small>
   End Date:
<input type="text" name="endDate" size=20 id="endDate" tabindex="5">
<small><a href="javascript:showCal('endDate')"><img src="../images/Calendar-48.png" alt="Click for Calendar" width="23" height="23" border="0"></a></small> </td>
</tr>
<tr>
<td align="right">Location: </td>
<td><select name="location" id="location">
<option value="">SELECT A LOCATION</option>
<option value="Ladera Ranch">Ladera Ranch</option>
<option value="Irons in the Fire">Irons in the Fire</option>
<option value="San Clemente">San Clemente</option>
</select></td>
</tr>
<tr>
<td align="right">Customer Last name:</td>
<td><select name="lName" id="lName">
<option value="value">SELECT A CUSTOMER LAST NAME</option>
<?php
do {
?>
<option value="<?php echo $row_Recordset1['lName']?>"><?php echo $row_Recordset1['lName']?></option>
<?php
} while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
$rows = mysql_num_rows($Recordset1);
if($rows > 0) {
mysql_data_seek($Recordset1, 0);
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
}
?>
</select></td>
</tr>
<tr>
<td align="right">Comments Food:</td>
<td><input name="foodComment" type="text" id="foodComment" size="50" /></td>
</tr>
<tr>
<td align="right">Comments Server: </td>
<td><input name="serverComment" type="text" id="serverComment" size="50" /></td>
</tr>
<tr>
<td align="right">Server name:</td>
<td><select name="serverName" id="serverName">
<option value="value">SELECT A SERVER NAME</option>
<?php
do {
?>
<option value="<?php echo $row_Recordset2['serverName']?>"><?php echo $row_Recordset2['serverName']?></option>
<?php
} while ($row_Recordset2 = mysql_fetch_assoc($Recordset2));
$rows = mysql_num_rows($Recordset2);
if($rows > 0) {
mysql_data_seek($Recordset2, 0);
$row_Recordset2 = mysql_fetch_assoc($Recordset2);
}
?>
</select></td>
</tr>
<tr>
<td align="right"> </td>
<td> </td>
</tr>
<tr>
<td align="right"> </td>
<td><input type="submit" name="search" id="search" value="Commence Search" /></td>
</tr>
</table>
</form>
<p> </p>
</body>
</html>
<?php
mysql_free_result($Recordset1);

mysql_free_result($Recordset2);

mysql_free_result($Recordset3);

?>

AND HERE IS THE RESULTS PAGE

<?php require_once('../Connections/BFCONN.php'); ?>
<?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;
}
}

$colname1_Recordset1 = "-1";
if (isset($_POST['updated'])) {
$colname1_Recordset1 = $_POST['updated'];
}
$colname2_Recordset1 = "-1";
if (isset($_POST['location'])) {
$colname2_Recordset1 = $_POST['location'];
}
$colname3_Recordset1 = "-1";
if (isset($_POST['lName'])) {
$colname3_Recordset1 = $_POST['lName'];
}
$colname4_Recordset1 = "-1";
if (isset($_POST['foodComment'])) {
$colname4_Recordset1 = $_POST['foodComment'];
}
$colname5_Recordset1 = "-1";
if (isset($_POST['serverComment'])) {
$colname5_Recordset1 = $_POST['serverComment'];
}
$colname6_Recordset1 = "-1";
if (isset($_POST['menuItems'])) {
$colname6_Recordset1 = $_POST['menuItems'];
}

mysql_select_db($database_BFCONN, $BFCONN);
$query_Recordset1 = sprintf("SELECT * FROM BF_comments WHERE BF_comments.updated = %s AND BF_comments.lName = %s AND BF_comments.location = %s AND BF_comments.foodComment = %s AND BF_comments.serverComment = %s AND BF_comments.menuItems = %s ORDER BY BF_comments.updated", GETSQLValueString($colname1_Recordset1, "int"),GETSQLValueString($colname2_Recordset1, "int"),GETSQLValueString($colname3_Recordset1, "int"),GETSQLValueString($colname4_Recordset1, "int"),GETSQLValueString($colname5_Recordset1, "int"),GETSQLValueString($colname6_Recordset1, "int"));
$Recordset1 = mysql_query($query_Recordset1, $BFCONN) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);;
?>
 
Reply to this current thread  View this persons public profile  Send Private Message
   Re: advance search results page  
View this persons public profile  Gianluigi   12:55 13 Dec 2011  
   Re: advance search results page  
View this persons public profile  JohnMerlino   19:41 13 Dec 2011  
   Re: advance search results page  
View this persons public profile  Gianluigi   9:38 14 Dec 2011  
   Re: advance search results page  
View this persons public profile  JohnMerlino   13:55 14 Dec 2011  
   Re: advance search results page  
View this persons public profile  Gianluigi   15:07 14 Dec 2011  
   Re: advance search results page  
View this persons public profile  Elizabeth Halliday   13:01 27 Feb 2012  
   Issue with search GROUP_CONCAT function in search query.  
View this persons public profile  JonathanJarzembowski   14:22 17 Oct 2011  
   Re: Issue with search GROUP_CONCAT function in search query.  
View this persons public profile  Gianluigi   14:34 17 Oct 2011  
   Comma Seperated list Continued...  
View this persons public profile  JonathanJarzembowski   3:20 13 Oct 2011  
Last Visit: Wednesday 15 Jan, 2025 6:37 pm First |  Prev |  Next |  Last  
 Login
Username:  Password:    
Read Message Read Message   Unread message Unread message
Read message [popular] Read message [popular]   Unread message [popular] Unread message [popular]
Read message [locked] Read message [locked]   Unread message [locked] Unread message [locked]
All times are GMT-1

Jump to: