search question

va vandereyde 18 May, 2009
dear all

I implemented the search code as suggested by user 'benblee' on your forum. However, when I search for a part of a field (eg search for 'pierro' in the name field 'del pierro'), no results show up. Is there a solution for this?
Thanks and all the best
Gr GreyHead 18 May, 2009
Hi vandereyde,

You don't say what code you are using but you probably want something like
echo "WHERE `field_name` LIKE '%{value}%'";


Bob
va vandereyde 18 May, 2009
Code I use:
<?php
$search_array = array('client', 'serial', 'vehicle'); 
$where = array();
foreach ( $search_array as $search ) {
  $value = JRequest::getVar($search, '' , 'post');
  if ( $value ) {
    $where[] = " $search LIKE '$value%' ";
  }
}
if ( !empty($where) ) {
  echo " WHERE ".implode(' AND ', $where);
}?>


Changed
$value%
into
%$value%
and it works now

THANKS very much
This topic is locked and no more replies can be posted.