Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Search Interface

New Here ,
Sep 02, 2010 Sep 02, 2010

Copy link to clipboard

Copied

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?

TOPICS
Server side applications

Views

2.4K
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Sep 03, 2010 Sep 03, 2010

Copy link to clipboard

Copied

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.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 03, 2010 Sep 03, 2010

Copy link to clipboard

Copied

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);

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 04, 2010 Sep 04, 2010

Copy link to clipboard

Copied

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

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

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 04, 2010 Sep 04, 2010

Copy link to clipboard

Copied

I didn't find this thread - http://forums.adobe.com/thread/709406 -  to be helpful.  I had difficulty understanding it.

As I mentioned in my previous email, below is my recordset.  However, I'm not sure where I should include the MMColParam as you mentioned or what it should look like.  Your help is greatly appreciated.

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);

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 05, 2010 Sep 05, 2010

Copy link to clipboard

Copied

I'm not very sure that I understand correctly what exactly you need. I am trying (without success) to create a search page that searches multiple columns at the same time. In one of my unsuccessful attempts I stumbled upon a Dreamweaver function that could help you (that is if I understand you correctly). your search form action should redirect the user to the result page on submit. On the results page, go to your bindings tab and double click on your recordset to bring up the recordset properties box.

To create the database filter for the search, complete the fields in the

Filter area as follows:

• For the first Filter field, select the database column you want to

search.

• For the second Filter field, select how to filter your results: Contains,

Begins With, Ends With, or Numeric Comparisons.

• For the third Filter field, select Form Variable if your form uses

the POST method, or URL Parameter if it uses the GET method.

• For the fourth Filter field, enter the name of the search field from the

search page.

Hope this helps. Let me know.

Reandré

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 06, 2010 Sep 06, 2010

Copy link to clipboard

Copied

Hi Reandre

I am beyond that point.  I am following the steps that Lon Winters recommended.  I have completed those steps and am now receiving the following error message:  "colname is an invalid variable name; it does not appear in the SQL." Below is my recordset.


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_Donations = "-1";
if (isset($_GET['posting_title'])) {
  $colname_Donations = $_GET['posting_title'];
}
mysql_select_db($database_bridesmaidsrack_db, $bridesmaidsrack_db);
$query_Donations = sprintf("SELECT * FROM donations WHERE posting_title LIKE %MMColParam% OR size LIKE %MMColParam2% OR dress_condition LIKE %MMColParam3%  OR dress_length LIKE %MMColParam4% OR color LIKE %MMColParam5% OR city LIKE %MMColParam6% OR state LIKE %MMColParam7% OR email LIKE %MMColParam8% OR additional_details LIKE %MMColParam9% ORDER BY posting_title ASC", GetSQLValueString($colname_Donations, "text"),GetSQLValueString($colname_Donations, "text"),GetSQLValueString($colname_Donations, "text"),GetSQLValueString($colname_Donations, "text"),GetSQLValueString($colname_Donations, "text"),GetSQLValueString($colname_Donations, "text"),GetSQLValueString($colname_Donations, "text"),GetSQLValueString($colname_Donations, "text"),GetSQLValueString($colname_Donations, "text"));
$Donations = mysql_query($query_Donations, $bridesmaidsrack_db) or die(mysql_error());
$row_Donations = mysql_fetch_assoc($Donations);
$totalRows_Donations = mysql_num_rows($Donations);

mysql_select_db($database_bridesmaidsrack_db, $bridesmaidsrack_db);
$query_Donations = "SELECT * FROM donations ORDER BY posting_title ASC";
$Donations = mysql_query($query_Donations, $bridesmaidsrack_db) or die(mysql_error());
$row_Donations = mysql_fetch_assoc($Donations);

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 06, 2010 Sep 06, 2010

Copy link to clipboard

Copied

your code has two queries with the same php variable. also there's only one parameter for your first query instead of colname1, colname2, colname3, etc. for each parameter. basically your code is saying this:

Set a parameter to default value of -1 then if a URL parameter for posting_title is set then reset the parameter value to the URL parameter. With parameter set filter the database where anything in your database table contains the set parameter. Run the query but whoops, you have another query set to the same php variable right after that which basically says ignore everything that was just setup and now just select everything from the donations table without any filtering.

It's easier to provide information when the information being provided is understood. If you blindly paste a code without understanding it then it's difficult to explain your problems afterwards. Try to understand the helpful link I've provided earlier which fully explains the process. Pasting your same code three times in a thread is not helpful.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Sep 06, 2010 Sep 06, 2010

Copy link to clipboard

Copied

Sorry for not checking back sooner, been hectic.  With the suggestion that I made, you shouldn't have to touch the source code.it can all be done in the advanced recordset dialog.

To see where everything is, just start with a recordset in simple mode. Make the selections there to generate the query on just the one column.

Now, switch over to Advanced mode. Note the simple SQL that was generated from your selections in simple mode, and below that the Parameters. Basically you just want to duplicate what is already there for each search column in your database table as I mentioned before.  For example, if the first column is size and the second column is color - say the user enters "red". When the query runs, it will first look at the first column and will not find a match as red is not a size. Then it will lookmat the second column and return all records with red in the field.   This is not a very complex search, even when you add more of your columns into the mix. It becomes more complex when the users start entering things like "red medium" into the search box. But first things first.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 09, 2010 Sep 09, 2010

Copy link to clipboard

Copied

Below is the recordset that I have created after following your original suggestion.  When I run a test I get "no data".  Below is my recordset:


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;
}
}

$MMColParam_Recordset1 = "-1";
if (isset(Request.QueryString("search"))) {
  $MMColParam_Recordset1 = Request.QueryString("search");
}
$MMColParam2_Recordset1 = "-1";
if (isset(Request.QueryString("search"))) {
  $MMColParam2_Recordset1 = Request.QueryString("search");
}
$MMColParam3_Recordset1 = "-1";
if (isset(Request.QueryString("search"))) {
  $MMColParam3_Recordset1 = Request.QueryString("search");
}
$MMColParam4_Recordset1 = "-1";
if (isset(Request.QueryString("search"))) {
  $MMColParam4_Recordset1 = Request.QueryString("search");
}
$MMColParam5_Recordset1 = "-1";
if (isset(Request.QueryString("search"))) {
  $MMColParam5_Recordset1 = Request.QueryString("search");
}
$MMColParam6_Recordset1 = "-1";
if (isset(Request.QueryString("search"))) {
  $MMColParam6_Recordset1 = Request.QueryString("search");
}
$MMColParam7_Recordset1 = "-1";
if (isset(Request.QueryString("search"))) {
  $MMColParam7_Recordset1 = Request.QueryString("search");
}
$MMColParam8_Recordset1 = "-1";
if (isset(Request.QueryString("search"))) {
  $MMColParam8_Recordset1 = Request.QueryString("search");
}
$MMColParam9_Recordset1 = "-1";
if (isset(Request.QueryString("search"))) {
  $MMColParam9_Recordset1 = Request.QueryString("search");
}
mysql_select_db($database_bridesmaidsrack_db, $bridesmaidsrack_db);
$query_Recordset1 = sprintf("SELECT * FROM donations WHERE posting_title LIKE %s OR size LIKE %s OR dress_condition LIKE %s OR dress_length LIKE %s OR color LIKE %s OR city LIKE %s OR state LIKE %s OR email LIKE %s OR additional_details LIKE %s ORDER BY posting_title ASC", GetSQLValueString("%" . $MMColParam_Recordset1 . "%", "text"),GetSQLValueString("%" . $MMColParam2_Recordset1 . "%", "text"),GetSQLValueString("%" . $MMColParam3_Recordset1 . "%", "text"),GetSQLValueString("%" . $MMColParam4_Recordset1 . "%", "text"),GetSQLValueString("%" . $MMColParam5_Recordset1 . "%", "text"),GetSQLValueString("%" . $MMColParam6_Recordset1 . "%", "text"),GetSQLValueString("%" . $MMColParam7_Recordset1 . "%", "text"),GetSQLValueString("%" . $MMColParam8_Recordset1 . "%", "text"),GetSQLValueString("%" . $MMColParam9_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);

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Sep 10, 2010 Sep 10, 2010

Copy link to clipboard

Copied

Hello Alicia - I see what's going on, and I fear I have lead you astray by mixing up ASP and PHP. Please accept my apologies. So I figured I owed it to you to create a little app myself and test it so I can be sure I'm giving you accurate information. You still did well in the process, just a couple tweaks needed.

First off, the MMColParam variables are what DW uses with ASP pages. the PHP counterpart is simply "colname". Another difference, in the Advanced Recordset dialog in ASP you have "Parameters", PHP it's "Variables". And since they are variables, it really doesn't matter what variable names you use - and you did set it up correctly with the MMColParam names, so that's not the problem. (personally tho, I would go back to the colname vars, easier to remember and type).

The main issue I see is the use of "Request.Querystring("xxxxxx") which is ASP. So, you will need to use $_GET['xxxxxxx'] instead. For example, this snippet:

$MMColParam_Recordset1 = "-1";

if (isset(Request.QueryString("search"))) {

  $MMColParam_Recordset1 = Request.QueryString("search"); }

Becomes:

$MMColParam_Recordset1 = "-1";

if (isset($_GET['search'])) {

  $MMColParam_Recordset1 = (get_magic_quotes_gpc()) ? $_GET['search'] : addslashes($_GET['search']);

}

Note the additional bit in the third line so overall it may be more than just making those replacements. Also, on your search page check to see if the form submit is set to GET or POST. Typically a form submission uses POST in which case $_GET['xxxxxxx'] would need to be changed to $_POST['xxxxxxx']. Either way will work however.

So here's my demo app - check it out and see if it functions as what you're building:

http://www.lonwintersmedia.com/demo/search.php

I've also attached a screenshot of the advanced recordset window - now that you have more accurate info, you should be able to configure everything in this window, but let me know if you'd like to see the code.

advanced_recordset_dialog.jpg

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 10, 2010 Sep 10, 2010

Copy link to clipboard

Copied

First let me give credit where it is due.  reandre68 helped me write the script, well actually wrote the script.

I made the changes you suggested but am getting a "no data" message when I run a test.  But before I post my records, can you post the code so that I make sure I'm doing everything the way it should be.  Thank you.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Sep 12, 2010 Sep 12, 2010

Copy link to clipboard

Copied

Ah, I didn't think I was the one giving you the "Request.Querystring" code.

How are you running th e test when you say you test it and get No Data? If it's from the recordset dialog, you won't get results because it is using the default values in each of your variables for the search criteria. You would need to temporarily change the default values to actual search terms to mimic run-time search values.

Also, someone should have mentioned this before, but please take a look at this thread for how to post code in your posts, it makes it much easier to read:   http://forums.adobe.com/thread/427712 

Here's the source from my demo page - but keep in mind that other than the recordset, there are other things that will lead to unsuccessful results including how your search page is set up to other elements on your results page. Have you tried building this using only one or two variables/column? It's usually better to build and test with more limited data to rule out other issues first.

<?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_rsColors = "-1";

if (isset($_POST['inputColor'])) {

  $colname_rsColors = (get_magic_quotes_gpc()) ? $_POST['inputColor'] : addslashes($_POST['inputColor']);

}

$colname2_rsColors = "-1";

if (isset($_POST['inputColor'])) {

  $colname2_rsColors = (get_magic_quotes_gpc()) ? $_POST['inputColor'] : addslashes($_POST['inputColor']);

}

$colname3_rsColors = "-1";

if (isset($_POST['inputColor'])) {

  $colname3_rsColors = (get_magic_quotes_gpc()) ? $_POST['inputColor'] : addslashes($_POST['inputColor']);

}

$colname4_rsColors = "-1";

if (isset($_POST['inputColor'])) {

  $colname4_rsColors = (get_magic_quotes_gpc()) ? $_POST['inputColor'] : addslashes($_POST['inputColor']);

}

$colname5_rsColors = "-1";

if (isset($_POST['inputColor'])) {

  $colname5_rsColors = (get_magic_quotes_gpc()) ? $_POST['inputColor'] : addslashes($_POST['inputColor']);

}

$colname6_rsColors = "-1";

if (isset($_POST['inputColor'])) {

  $colname6_rsColors = (get_magic_quotes_gpc()) ? $_POST['inputColor'] : addslashes($_POST['inputColor']);

}

$colname7_rsColors = "-1";

if (isset($_POST['inputColor'])) {

  $colname7_rsColors = (get_magic_quotes_gpc()) ? $_POST['inputColor'] : addslashes($_POST['inputColor']);

}

mysql_select_db($database_demoConn, $demoConn);

$query_rsColors = sprintf("SELECT * FROM colorTable WHERE color1 LIKE %s OR color2 LIKE %s OR color3 LIKE %s OR color4 LIKE %s OR color5 LIKE %s OR color6 LIKE %s OR color7 LIKE %s", GetSQLValueString("%" . $colname_rsColors . "%", "text"),GetSQLValueString("%" . $colname2_rsColors . "%", "text"),GetSQLValueString("%" . $colname3_rsColors . "%", "text"),GetSQLValueString("%" . $colname4_rsColors . "%", "text"),GetSQLValueString("%" . $colname5_rsColors . "%", "text"),GetSQLValueString("%" . $colname6_rsColors . "%", "text"),GetSQLValueString("%" . $colname7_rsColors . "%", "text"));

$rsColors = mysql_query($query_rsColors, $demoConn) or die(mysql_error());

$row_rsColors = mysql_fetch_assoc($rsColors);

$totalRows_rsColors = mysql_num_rows($rsColors);

?>

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 17, 2010 Sep 17, 2010

Copy link to clipboard

Copied

After making the suggested changes, I am getting this error message:


Parse error: syntax error, unexpected '.', expecting T_PAAMAYIM_NEKUDOTAYIM in C:\xampp\htdocs\bridesmaidsrack\searchtest.php on line 8

Below is my code:


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;
}
}

$maxRows_Recordset1 = 10;
$pageNum_Recordset1 = 0;
if (isset($_GET['pageNum_Recordset1'])) {
  $pageNum_Recordset1 = $_GET['pageNum_Recordset1'];
}
$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;

$colname_Recordset1 = "-1";
if (isset($_GET['inputPosting_title'])) {
  $colname_Recordset1 = $_GET['inputPosting_title'];
}
$colname2_Recordset1 = "-1";
if (isset($_GET['inputSize'])) {
  $colname2_Recordset1 = $_GET['inputSize'];
}
mysql_select_db($database_bridesmaidsrack_db, $bridesmaidsrack_db);
$query_Recordset1 = sprintf("SELECT * FROM donations WHERE posting_title LIKE %s OR size LIKE %s ", GetSQLValueString("%" . $colname_Recordset1 . "%", "text"),GetSQLValueString("%" . $colname2_Recordset1 . "%", "text"));
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_Recordset1, $bridesmaidsrack_db) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);

if (isset($_GET['totalRows_Recordset1'])) {
  $totalRows_Recordset1 = $_GET['totalRows_Recordset1'];
} else {
  $all_Recordset1 = mysql_query($query_Recordset1);
  $totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
}
$totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;

Thank you.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Sep 17, 2010 Sep 17, 2010

Copy link to clipboard

Copied

What is T_PAAMAYIM_NEKUDOTAYIM and is it included in your SQL? It looks like it is, but the associates variable is not defined. The only one I see defined is for "inputSize".

Let me ask you something - you are searching on several of your database columns, is that correct? Are you trying to get them all working at once, or have you tried with a simple search first? If not, you should just try that to make sure the basic search works. Is your search form set to GET or POST? Is 'inputSize the actual name and ID of your search textbox?

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 20, 2010 Sep 20, 2010

Copy link to clipboard

Copied

I Googled T_PAAMAYIM_NEKUDOTAYIM and this is what I found: http://at-byte.com/technology/tpaamayimnekudotayim-php-error.  However, I deleted my the page and recreated it and am no longer getting that error message.

To answer your questions, yes, I am searching several of my database columns.  I have tried a simple search and it works when I test it in the recordset, but I try to display the results, I get no results.  My search form is set to Post.  inputSize is not the actual name of my id search textbox; it is size.

I am now starting simple and have created a simple recordset.  However, as mentioned above, it works when I test it in the recordset, but there I get nothing when I try to display the results.  Below is the code for my new simple recordset.

Thanks for your help.


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 ORDER BY posting_title ASC", 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);

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Sep 21, 2010 Sep 21, 2010

Copy link to clipboard

Copied

Ok, almost there I think:

This:

$colname_Recordset1 = "-1";
if (isset($_GET['posting_title'])) {
  $colname_Recordset1 = $_GET['posting_title'];
}

Should be:

$colname_Recordset1 = "-1";
if (isset($_POST['size'])) {
  $colname_Recordset1 = $_POST['size'];
}

OR, change the name of the search text box to posting_title, then you code would be:

$colname_Recordset1 = "-1";
if (isset($_POST['posting_title'])) {
  $colname_Recordset1 = $_POST['posting_title'];
}

Just so it matches, thats the key. That code is generated by the recordset dialog. If you're in Simple mode, in the one dropdown menu where you make a selection, you chose "URL Parameter" which is GET. "Form Variable" means POST, so that has to match what the search form  is set to, POST is the default setting.

To the right of the drop down, is the field where you enter the name of the form variable which has to match the name of the search text box - so your search box was named size, but you must have entered posting_title. I can see what may have lead you there as that is the name of the column in your database.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 21, 2010 Sep 21, 2010

Copy link to clipboard

Copied

I made the recommended changes but am still not seeing any results displayed.

Thanks for your help.


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($_POST['posting_title'])) {
  $colname_Recordset1 = $_POST['posting_title'];
}
mysql_select_db($database_bridesmaidsrack_db, $bridesmaidsrack_db);
$query_Recordset1 = sprintf("SELECT * FROM donations WHERE posting_title = %s ORDER BY posting_title ASC", 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);

$colname_Recordset1 = "-1";
if (isset($_POST['posting_title'])) {
  $colname_Recordset1 = $_POST['posting_title'];
}
mysql_select_db($database_bridesmaidsrack_db, $bridesmaidsrack_db);
$query_Recordset1 = sprintf("SELECT * FROM donations WHERE posting_title = %s ORDER BY posting_title ASC", GetSQLValueString($colname_Recordset1, "text"));
$Recordset1 = mysql_query($query_Recordset1, $bridesmaidsrack_db) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Sep 21, 2010 Sep 21, 2010

Copy link to clipboard

Copied

Did you also change the name of your search box to match pasting_title? 

There's also a block of code that's repeated, even different from your previous example - did you notice that?

I don't know if you can zip and upload the actual files here, do that if it's allowed. Otherwise, I would suggest you find some tutorials on creating simple searches with results in Dreamweaver. A tutorial will walk you through step by step what to do and will also help you understand the concepts - without that, it's very difficult to troubleshoot because you don't know what to look for.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 24, 2010 Sep 24, 2010

Copy link to clipboard

Copied

So I finally got it to work.  The problem was exactly what you mentioned (Did you also change the name of your search box to match pasting_title?).

I am now going to try to create an advanced search so that I can search all of the columns.  I am going to use the suggestions that you gave before and will let you know whether or not it has worked.

Thanks again for your help.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 24, 2010 Sep 24, 2010

Copy link to clipboard

Copied

It works perfectly.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Sep 25, 2010 Sep 25, 2010

Copy link to clipboard

Copied

LATEST

Good to hear!  I'm glad you got it working - sometimes these things are a struggle, but so rewarding when it finally clicks in to lace and especially when you know what went wrong and you can clearly see what was going on, why it wasn't working and how that understanding will benefit you in future projects.

Now if I make just one more suggestion, something I wish I had done way back when. Make yourself some sort of code library - even if it's just a group of folders on your computer with copies of certain pages, or just copy certain snippets into text files. Perhaps also include a text file or Word document that describes what the pages do and any other comments or notes you may find useful at a later date. I don't know how many times I set out to do something only vaguely remembering that I'd done it before or something similar, but had to search through various sites and dozens of files to find it. And often, it was just fro little things like what is the correct syntax to use.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines