Search in CC _ consolidate several values in one

purple knight 08 Aug, 2009
Hallo Bob & Max,

Looks like both of you have been very busy. Hope Chronoengine continues to be popular & attracts more users!

Getting a lot of help from this forum, I have set up my Chronoform & Connectivity. Lately some users gave feedback on my site & I hope to address them to make it better. This is a question on Chronoconnectivity. I am not sure what's the key word to describe, so bear with my long writing. 😶
In Chronoform, users can choose & click the right specific price among several values. (ie, 3000, 3100, 3200, 3300, 3400, 3500, 3600, 3700, 3800, 3900, 4000 etc). This step works fine.

In my Chronoconnectivity page, there is a search option. I want to allow guests to quickly search. Thus, the drop down options should be a consolidated result. (ie 3000, 3100, 3200 to be consolidated into 3000-3200 & 3300, 3400, 3500 to become 3300-3500, etc).

So you know of any basic way to achieve this? 😀
GreyHead 08 Aug, 2009
Hi PurpleKnight,

Something like this:Form HTML
<option value='3000:3500'>3,000 - 3,500</option>
Where clause
<?php
$where = array();
$price_range = JRequest::getString('price_range', '', 'post');
if ( $price_range ) {
  $price_range = explode(':', $price_range);
  $where[] = "`price` > ".$price_range[0]." AND `price` <= ".$price_range[1];
}
. . .
if ( !empty($where) ) {
  echo = "WHERE ".implode(' AND ', $where)." ";  
}
?>

Bob
purple knight 08 Aug, 2009
Hallo Bob,

Thanks a lot for your help! 😀

My "where sql" now looks like
<?php
$search_array = array('select_32', 'select_2'); 
$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);
}
echo " ORDER BY cf_id DESC ";
?>


Wonder which part should I modify?

The page is at http://www.purplerice.com.cn/index.php/apartments
GreyHead 08 Aug, 2009
Hi PurpleKnight,

In here I think
. . .
}
// add extra Where clauses here
$price_range = JRequest::getString('price_range', '', 'post');
if ( $price_range ) {
  $price_range = explode(':', $price_range);
  $where[] = "`price` > ".$price_range[0]." AND `price` <= ".$price_range[1];
}
// leave the rest alone
if ( !empty($where) ) {
. . .

Bob
purple knight 09 Aug, 2009
Hmmm... a little puzzled. In other words, you mean...?
GreyHead 09 Aug, 2009
Hi PurpleKnight,

Put the code where I put it.

Bob
This topic is locked and no more replies can be posted.