|
DwZone Forum Welcome to the DwZone-it Forum
|
Advanced Search |
|
DwZone Forum Index -> Advanced Search Moderators:
Administrators, Moderators |
Mark all topics read |
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. |
Subject |
Author
|
Date |
|
|
|
JohnMerlino |
21:25 12 Dec 2011 |
|
|
Gianluigi |
12:55 13 Dec 2011 |
|
|
JohnMerlino |
19:41 13 Dec 2011 |
|
the DISTINCT record sets are to populate the d_r_o_p down boxes with only distinct information from the comments table. The comments table can have multiple name the same and multiple dates the same. I am not an expert at coding so I sometimes do what works, I know it may not always be the cleanest and most efficient but it is what my knowledge allows at this stage.
So I need to create
1- the search form with just an action to post to the next page. 2- A results page with the advanced search behavior with all of the fields I want to display in it from the BG_comments table right?
Just want to make sure I understand.
Also in my search form am I able to create a recordset to populate the d_r_o_p downs with the necessary data. Inputting this would not work, it needs to be dynamic.
OK SO HERE IS MY NEW SEARCH FORM called mainSearch.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_DISTINCT_RS = "SELECT * FROM vw_distinct"; $DISTINCT_RS = mysql_query($query_DISTINCT_RS, $BFCONN) or die(mysql_error()); $row_DISTINCT_RS = mysql_fetch_assoc($DISTINCT_RS); $totalRows_DISTINCT_RS = mysql_num_rows($DISTINCT_RS); ?> <!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 Database</title> <script language="javascript" src="js/cal2.js"></script> <script language="javascript" src="js/cal_conf2.js"></script> </head>
<body> <form id="mainSearch" name="mainSearch" method="post" action="results.php"> <table width="75%" border="0" align="center" cellpadding="4" cellspacing="4"> <tr> <td colspan="2"><h2>Perform a search of the Comments Database</h2></td> </tr> <tr> <td width="31%" align="right"><strong>Date Range:</strong></td> <td width="69%">Start Date: <input type="text" name="startDate" size=20 id="updated" 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="updated" 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"><strong>Customer Last Name:</strong></td> <td><select name="lName" id="lName" tabindex="2"> <option>SELECT A CUSTOMER LAST NAME</option> <?php do { ?> <option value="<?php echo $row_DISTINCT_RS['lName']?>"><?php echo $row_DISTINCT_RS['lName']?></option> <?php } while ($row_DISTINCT_RS = mysql_fetch_assoc($DISTINCT_RS)); $rows = mysql_num_rows($DISTINCT_RS); if($rows > 0) { mysql_data_seek($DISTINCT_RS, 0); $row_DISTINCT_RS = mysql_fetch_assoc($DISTINCT_RS); } ?> </select></td> </tr> <tr> <td align="right"><strong>Search by Server:</strong></td> <td><select name="serverName" id="serverName" tabindex="4"> <option>SELECT A SERVERS NAME</option> <?php do { ?> <option value="<?php echo $row_DISTINCT_RS['serverName']?>"><?php echo $row_DISTINCT_RS['serverName']?></option> <?php } while ($row_DISTINCT_RS = mysql_fetch_assoc($DISTINCT_RS)); $rows = mysql_num_rows($DISTINCT_RS); if($rows > 0) { mysql_data_seek($DISTINCT_RS, 0); $row_DISTINCT_RS = mysql_fetch_assoc($DISTINCT_RS); } ?> </select></td> </tr> <tr> <td align="right"><strong>Search by Location</strong></td> <td><select name="location" id="location" tabindex="5"> <option>SELECT A LOCATION</option> <option value="Ladera Ranch">Ladera Ranch</option> <option value="San Clemente">San Clemente</option> <option value="Irons in the Fire">Irons in the Fire</option> </select></td> </tr> <tr> <td align="right"><strong>Search a Food Comment</strong></td> <td><input name="foodComment" type="text" id="foodComment" tabindex="6" size="30" /></td> </tr> <tr> <td align="right"><strong>Search A Server Comment</strong></td> <td><input name="serverComment" type="text" id="serverComment" tabindex="7 size=" size="30"60" /></td> </tr> <tr> <td align="right"><strong>Search by Daypart</strong></td> <td><select name="daypart" id="daypart" tabindex="8"> <option>SELECT A DAYPART</option> <option value="DAY">Daytime</option> <option value="EVE">Evening</option> </select></td> </tr> <tr> <td align="right"><input type="submit" name="search" id="search" value="Submit Now!" /></td> <td><input type="submit" name="reset" id="reset" value="RESET" /></td> </tr> </table> </form> </body> </html> <?php mysql_free_result($DISTINCT_RS); ?>
AND HERE IS MY RESULTS PAGE results.php (Which gets an sql error form the dates: (You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'between '2011/12/01' AND '2011/12/13'))' at line 1)
<?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 * 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); ?> <?php //************************** // Advanced Search // http://www.DwZone-it.com // Version: 1.0.2 //************************** $dwzSearch_1 = new dwzSearch(); $dwzSearch_1->Init(); $dwzSearch_1->SetFormName(""); $dwzSearch_1->SetSubmitName(""); $dwzSearch_1->AddFilter("", "Between", "updated", "startDate", "endDate", "S", "0"); $dwzSearch_1->AddFilter("", "=", "daypart", "daypart", "", "S", "0"); $dwzSearch_1->AddFilter("", "Like", "serverComment", "serverComment", "", "S", "0"); $dwzSearch_1->AddFilter("", "Like", "foodComment", "foodComment", "", "S", "0"); $dwzSearch_1->AddFilter("", "=", "location", "location", "", "S", "0"); $dwzSearch_1->AddFilter("", "=", "serverName", "serverName", "", "S", "0"); $dwzSearch_1->SetRecordset($Recordset1, "Recordset1"); $dwzSearch_1->SetSql($query_Recordset1); $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>Untitled Document</title> <link href="css/search_css.css" rel="stylesheet" type="text/css" /> </head>
<body> <div id="searchWrapper"> <div id="lastName"> <input name="commentID" type="hidden" id="commentID" value="<?php echo $row_Recordset1['commentID']; ?>" /> <?php echo $row_Recordset1['fName']; ?> <?php echo $row_Recordset1['lName']; ?></div> <br /> <br /> <div id="serveName"><?php echo $row_Recordset1['serverName']; ?></div> <br /> <br /> <div id="serverComments"><?php echo $row_Recordset1['serverComment']; ?></div> <br /> <br /> <div id="menuItems"><?php echo $row_Recordset1['menuItems']; ?></div> <br /> <br /> <div id="menuComments"><?php echo $row_Recordset1['foodComment']; ?></div> <br /> <br /> <div id="Location"><?php echo $row_Recordset1['location']; ?></div> <br /> <br /> <div id="Daypart"><?php echo $row_Recordset1['daypart']; ?></div> <br /> <br /> <div id="inputby"><?php echo $row_Recordset1['daypart']; ?></div> <br /> <br /> <div id="followup"><?php echo $row_Recordset1['followup']; ?></div> </div> </body> </html> <?php mysql_free_result($Recordset1); ?>
|
|
|
|
|
|
|
Gianluigi |
9:38 14 Dec 2011 |
|
|
JohnMerlino |
13:55 14 Dec 2011 |
|
|
Gianluigi |
15:07 14 Dec 2011 |
|
|
Elizabeth Halliday |
13:01 27 Feb 2012 |
|
|
|
JonathanJarzembowski |
14:22 17 Oct 2011 |
|
|
Gianluigi |
14:34 17 Oct 2011 |
|
|
|
JonathanJarzembowski |
3:20 13 Oct 2011 |
|
|
|
|
|
Read Message |
Unread message |
Read message [popular] |
Unread message [popular] |
Read message [locked] |
Unread message [locked] |
|
All times are GMT-1
|
|