Skip to main content
Known Participant
September 3, 2010
Question

Search Interface

  • September 3, 2010
  • 1 reply
  • 2744 views

I am about to pull my hair out one strand at a time.  I am trying desperately to create an advanced recordset. I need this explained to me in the simpliest of terms.  I have a table that has nine columns:  posting title, size, dress condition, dress length, color, city, state, email and additional details. I want visitors to my site to receive results based on whatever keyword they choose to search by.  So for example, they should receive a result whether they type in the name of a city or a color.  How do I filter this?

This topic has been closed for replies.

1 reply

Lon_Winters
Inspiring
September 3, 2010

So you're going to have a single text input field on the search page? Try this:

Start off by creating a simple recordset, select the first column from your table, change "=" to "contains", select form variable then enter the name of the text input field. Now go to advanced view and the SQL should look something like thisL

SELECT *

FROM table

WHERE column1 LIKE %MMColParam%

Now, just add the rest of the columns and parameters, such as:

SELECT *

FROM table

WHERE column1 LIKE %MMColParam% OR column2 LIKE %MMColParam2% OR column3 LIKE %MMColParam3% and so on.

Then in the Parameters section, add all the parameters to match - the first will be ther, MMColParam, you'll have to add MMColParam2, 3 and so on. For the other details, the value will be the same for all, you may have to change the Type and default value. Try % or %% for default value for "All:.

If the results are too broad, you can change the statement from LIKE to equals, or remove the first % (MMColParam%) which means start with instead of contains.

Known Participant
September 4, 2010

This is what I have done so far. I am unsure where the PARAMETERS section is so that I may include MMColParam.

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_Recordset1 = "-1";
if (isset($_GET['posting_title'])) {
  $colname_Recordset1 = $_GET['posting_title'];
}
mysql_select_db($database_bridesmaidsrack_db, $bridesmaidsrack_db);
$query_Recordset1 = sprintf("SELECT * FROM donations WHERE posting_title = %s OR size = %s OR dress_condition = %s  OR dress_length = %s OR color = %s OR city = %s OR state = %s OR email = %s OR additional_details = %s ORDER BY posting_title ASC", GetSQLValueString($colname_Recordset1, "text"),GetSQLValueString($colname_Recordset1, "text"),GetSQLValueString($colname_Recordset1, "text"),GetSQLValueString($colname_Recordset1, "text"),GetSQLValueString($colname_Recordset1, "text"),GetSQLValueString($colname_Recordset1, "text"),GetSQLValueString($colname_Recordset1, "text"),GetSQLValueString($colname_Recordset1, "text"),GetSQLValueString($colname_Recordset1, "text"));
$Recordset1 = mysql_query($query_Recordset1, $bridesmaidsrack_db) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);

mysql_select_db($database_bridesmaidsrack_db, $bridesmaidsrack_db);
$query_Recordset1 = "SELECT * FROM donations ORDER BY posting_title ASC";
$Recordset1 = mysql_query($query_Recordset1, $bridesmaidsrack_db) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);

September 4, 2010

This is a duplicate post that has already been answered here:

http://forums.adobe.com/thread/709406