close ad
WARNING: Do Not Install the DREAMWEAVER CC 2017 or 2018 Update »
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Want results page to not show any records when Search submit is pressed

Thread began 4/23/2015 3:00 pm by JBWebWorks | Last modified 4/23/2015 9:39 pm by Ray Borduin | 781 views | 8 replies |

JBWebWorks

Want results page to not show any records when Search submit is pressed

My Code on results page

php:
<?php require_once('Connections/connpco1.php'); ?>

<?php 
require_once("webassist/database_management/wada_search.php"); ?>
<?php
//WA Database Search (Copyright 2005, WebAssist.com)
//Recordset: WADAplayer_info;
//Searchpage: ;
//Form: ;
$WADbSearch1_DefaultWhere "0!=0";
if (!
session_id()) session_start();
if (isset(
$_POST["search1"]) || isset($_POST["search1"])) {
  
$WADbSearch1 = new FilterDef;
  
$WADbSearch1->initializeQueryBuilder("MYSQL","1");
  
//keyword array declarations

  //comparison list additions
  
$WADbSearch1->addComparison("sponsor_DONOR","".((isset($_POST["sponsor1"]))?$_POST["sponsor1"]:"")  ."","AND","Includes",0);
  
$WADbSearch1->addComparison("player_1_name","".((isset($_POST["player1"]))?$_POST["player1"]:"")  ."","AND","Includes",0);
  
$WADbSearch1->addComparison("player_2_name","".((isset($_POST["player2"]))?$_POST["player2"]:"")  ."","AND","Includes",0);
  
$WADbSearch1->addComparison("entrydate","2015/03/01","AND",">=",2);

  
//save the query in a session variable
  
if (== 1) {
    
$_SESSION["WADbSearch1_Registered_Players_Information"]=$WADbSearch1->whereClause;
  }
}
else     {
  
$WADbSearch1 = new FilterDef;
  
$WADbSearch1->initializeQueryBuilder("MYSQL","1");
  
//get the filter definition from a session variable
  
if (== 1)     {
    if (isset(
$_SESSION["WADbSearch1_Registered_Players_Information"]) && $_SESSION["WADbSearch1_Registered_Players_Information"] != "")     {
      
$WADbSearch1->whereClause $_SESSION["WADbSearch1_Registered_Players_Information"];
    }
    else     {
      
$WADbSearch1->whereClause $WADbSearch1_DefaultWhere;
    }
  }
  else     {
    
$WADbSearch1->whereClause $WADbSearch1_DefaultWhere;
  }
}
$WADbSearch1->whereClause str_replace("\\''""''"$WADbSearch1->whereClause);
$WADbSearch1whereClause '';
?>
<?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;
}
}
?>
<?php
$currentPage 
$_SERVER["PHP_SELF"];
?>
<?php
$maxRows_WADAplayer_info 
10;
$pageNum_WADAplayer_info 0;
if (isset(
$_GET['pageNum_WADAplayer_info'])) {
  
$pageNum_WADAplayer_info $_GET['pageNum_WADAplayer_info'];
}
$startRow_WADAplayer_info $pageNum_WADAplayer_info $maxRows_WADAplayer_info;

mysql_select_db($database_connpco1$connpco1);
$query_WADAplayer_info "SELECT ID, sponsor_DONOR, player_1_name, player_2_name, player_1_address, player_2_address, player_1_city, player_2_city, player_1_zip, player_2_zip, player_1_phone, player_2_phone, player_1_email, player_2_email, player_1_hdcp, player_2_hdcp, first_day_am_pm, second_day_am_pm FROM player_info";
setQueryBuilderSource($query_WADAplayer_info,$WADbSearch1,false);
$query_limit_WADAplayer_info sprintf("%s LIMIT %d, %d"$query_WADAplayer_info$startRow_WADAplayer_info$maxRows_WADAplayer_info);
$WADAplayer_info mysql_query($query_limit_WADAplayer_info$connpco1) or die(mysql_error());
$row_WADAplayer_info mysql_fetch_assoc($WADAplayer_info);

if (isset(
$_GET['totalRows_WADAplayer_info'])) {
  
$totalRows_WADAplayer_info $_GET['totalRows_WADAplayer_info'];
} else {
  
$all_WADAplayer_info mysql_query($query_WADAplayer_info$connpco1);
  
$totalRows_WADAplayer_info mysql_num_rows($all_WADAplayer_info);
}
$totalPages_WADAplayer_info ceil($totalRows_WADAplayer_info/$maxRows_WADAplayer_info)-1;
?>
<?php
$queryString_WADAplayer_info 
"";
if (!empty(
$_SERVER['QUERY_STRING'])) {
  
$params explode("&"$_SERVER['QUERY_STRING']);
  
$newParams = array();
  foreach (
$params as $param) {
    if (
stristr($param"pageNum_WADAplayer_info") == false && 
        
stristr($param"totalRows_WADAplayer_info") == false) {
      
array_push($newParams$param);
    }
  }
  if (
count($newParams) != 0) {
    
$queryString_WADAplayer_info "&" htmlentities(implode("&"$newParams));
  }
}
$queryString_WADAplayer_info sprintf("&totalRows_WADAplayer_info=%d%s"$totalRows_WADAplayer_info$queryString_WADAplayer_info);
?>
<?php
//WA AltClass Iterator
class WA_AltClassIterator     {
  var 
$DisplayIndex;
  var 
$DisplayArray;
  
  function 
WA_AltClassIterator($theDisplayArray = array(1)) {
    
$this->ClassCounter 0;
    
$this->ClassArray   $theDisplayArray;
  }
  
  function 
getClass($incrementClass)  {
    if (
sizeof($this->ClassArray) == 0) return "";
      if (
$incrementClass) {
      if (
$this->ClassCounter >= sizeof($this->ClassArray)) $this->ClassCounter 0;
      
$this->ClassCounter++;
    }
    if (
$this->ClassCounter 0)
      return 
$this->ClassArray[$this->ClassCounter-1];
    else
      return 
$this->ClassArray[0];
  }
}
?>
<?php
//WA Alternating Class
$WARRT_AltClass1 = new WA_AltClassIterator(explode("|""|WADAResultsRowDark"));
?>
Sign in to reply to this post

Ray BorduinWebAssist

You mean when submit is pressed without filling any field values in? It looks like that would work with the current code.

Do you have a URL where I can see the problem? I may need FTP access to debug it as well.

Sign in to reply to this post

JBWebWorks

http://www.pcogolf.org/Registered_Players_Search.php

have only two records as of now for testing. When Search button is pressed it shows both records. I would rather it not show any records.

thanks,
Jim Balthrop

Sign in to reply to this post

Ray BorduinWebAssist

I think just add this before the recordset code after the search code:

if (!$WADbSearch1->whereClause) $WADbSearch1->whereClause = $WADbSearch1_DefaultWhere;

Sign in to reply to this post

JBWebWorks

Ray,

I added that line as

php:
if (1 == 1)     {

    if (isset($_SESSION["WADbSearch1_Registered_Players_Information"]) && $_SESSION["WADbSearch1_Registered_Players_Information"] != "")     {
      $WADbSearch1->whereClause = $_SESSION["WADbSearch1_Registered_Players_Information"];
    }
    else     {
      $WADbSearch1->whereClause = $WADbSearch1_DefaultWhere;
    }
  }
  else     {
    $WADbSearch1->whereClause = $WADbSearch1_DefaultWhere;
  }
}
$WADbSearch1->whereClause = str_replace("\\''", "''", $WADbSearch1->whereClause);
$WADbSearch1whereClause = '';
if (!$WADbSearch1->whereClause) $WADbSearch1->whereClause = $WADbSearch1_DefaultWhere;
?>




Still shows all records when the search button is pressed?

Sign in to reply to this post

Ray BorduinWebAssist

Seems like that would work... can you give me FTP access so I can debug it?

Sign in to reply to this post

JBWebWorks

Ray see PM

Sign in to reply to this post

Ray BorduinWebAssist

I see... this didn't work because you had hard coded a date search into the Database Search server behavior, so technically there was always a search being performed.

I fixed the problem by adding the date search directly to the where clause and removing it from the list of comparisons for DataAssist Search. This fixed the problem.

Sign in to reply to this post

JBWebWorks

GREAT!

Thanks Ray for your help.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...