Exclude null values from Search results

B

Balmain

Guest
How do I exclude records from my search results that do not have a value in a field. eg. I have 1325 entries in a database with a comment field for each. I only want to show those records that have something in the comment field.

Graham
 
E

Eugenio

Guest
Balmain wrote:

> How do I exclude records from my search results that do not
> have a value in a field. eg. I have 1325 entries in a database
> with a comment field for each. I only want to show those
> records that have something in the comment field.

It is not possible at the moment.



(Latest version of DaDaBIK when this message was posted: 3.1 beta)
 
H

Hugo

Guest
Hi,
I use dadabik 3.0
and the tip is:(sorry I have no line-numbers)
adapt it to your needs

In form.php you can find this piece of code:

case "search":

// build the select query
if (!isset($where_clause)){ // it's a search result, the
user has just filled the search form, so we have to build the select
query
$where_clause = build_where_clause($_POST,
$fields_labels_ar, $table_name);
} // end if


Below this, you can add this to exclude records from your query:

$extra_whereclause = "yourfieldname <> ''";

if ($where_clause != "") {
$where_clause .= " AND " . $extra_whereclause;
} else {
$where_clause = $extra_whereclause;
}

--
Greetings,
Hugo
 
Top