php - display search result with jquery on smarty template -


i trying display search result in <div> on smarty template. search result taken click.

the anchor this:

<li class="price-list-item"><a href="javascript:void();" class="price" onclick="searchrange(0,1000)">0-1000</a></li> 

and searchrange function this:

function searchrange(first, second) {         var first = first;     var second = (second != null) ? second : first;      $("#ad-display").load("index.php?first="+first+"&second="+second+" #ad-display"); } 

the ad-display box written in adlistdisplay.tpl looks this:

<div id="ad-display">     <section id="add-list">         <ul id="ad-list">         {foreach from=$adverts key=k item=i name=ad_list}             <li class="ad-list-item-{cycle values="odd,even"}" id="ad-{$i.aid}">                 <div class="ad-item-box">                     <div class="ad-item-photo">                         <a href="viewad.php?aid={$i.aid}"><img src="adimages/{$i.img}" width="80" height="80"></a>                     </div>                     <div class="ad-item-info">                         <span class="ad-item-title"><a href="viewad.php?aid={$i.aid}">{$i.title}</a></span>                         <span class="ad-item-desc">{$i.text|truncate:25}</span>                         <span class="ad-item-price">kr. {$i.price|number_format:2:",":"."}</span>                     </div>                 </div>             </li>           {/foreach}         </ul>                                 </section> </div> 

in index.php have code:

$adverts = new adverts(); $smarty->assign('catlist', $adverts->getcategories()); smartypaginate::assign($smarty);  if(isset($_get["first"])) {     $search = new searchengine();         $smarty->assign('adverts', $search->search_ads(null, "price", $_get["first"], $_get["second"]));     } else {     $smarty->assign('adverts', $adverts->listadverts());     }  $smarty->display('index.tpl'); 

index.tpl contains this:

{include file="adlistdisplay.tpl"} 

when click anchor @ top, shows blank spot @ #ad-display. no results displayed. want display result search_ads function. this:

function search_ads($search_string = null, $type, $min_price = null, $max_price = null) {          global $db;         global $config;          switch($type) {             case "text":                 $search = 'text "%'. $search_string .'%"';                 break;             case "price":                 $search = 'price > '. $min_price .' <= '. $max_price .'';                 break;             case "headline":                 $search = 'title "%'. $search_string .'%"';                 break;             default:                 $search = 'price between '. $min_price .' , '. $max_price .'';                 break;         }          $row = $db->dbh->query('select ad.*, (select img.image '.$config->db_prefix.'_images img img.aid = ad.aid limit 1) img '.$config->db_prefix.'_adverts ad '. $search .' , ad.approved = 1');                 $row->setfetchmode(pdo::fetch_assoc);         return $row;     }   

i have created fiddle show achieve. little different, shows intention

http://jsfiddle.net/xeaky/20/

solution:

$search = 'price > '. $min_price .' , price <= '. $max_price .''; 

solution posted @ bottom of question


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -