<?php if(isset($_POST['phrase'])&&$_POST['phrase']!=null){ $i=0; //searching in content $pPhrase = strtolower(addslashes($_POST['phrase'])); //searching in products $pQuery = "SELECT p.product_id,d.value as name,d2.value as description, p.alias FROM ftc_products p INNER JOIN ftc_dictionary d ON d.record_id=p.product_id INNER JOIN ftc_dictionary d2 ON d2.record_id=p.product_id WHERE d.type='product' AND d.language_id=1 AND d.field='name' AND d2.type='product' AND d2.language_id=1 AND d2.field='description' AND ( lower(d.value) like '%".$pPhrase."%' OR lower(d2.value) like '%".$pPhrase."%') "; $pRes = $modx->query($pQuery); while($pRow = $pRes->fetch()){ ?><li><h2><?php echo stripslashes($pRow['name']);?></h2><p><?php echo substr(strip_tags(stripslashes($pRow['description'])),0,150);?> <a href="/<?php echo "trip/".$pRow['alias'];?>" style="color:#8C1E05;" > more »</a></p></li><?php $i++; }//while $pQuery = "SELECT c.id,c.alias, d.value as content, d2.value as pagetitle FROM ftc_site_content c LEFT JOIN ftc_dictionary d ON d.record_id=c.id LEFT JOIN ftc_dictionary d2 ON d2.record_id=c.id WHERE d.type='content' AND d.field='content' AND d.language_id=1 AND d2.type='content' AND d2.field='pagetitle' AND d2.language_id=1 AND ( lower(d.value) like '%".$pPhrase."%' OR lower(d2.value) like '%".$pPhrase."%' )"; $pRes = $modx->query($pQuery); while($pRow = $pRes->fetch()){ ?><li><h2><?php echo stripslashes($pRow['pagetitle']);?></h2><p><?php echo substr(strip_tags(stripslashes($pRow['content'])),0,150);?> <a href="<?php echo $modx->makeUrl($pRow['id']);?>" style="color:#8C1E05;"> more »</a></p></li><?php $i++; }//while //search in blog $pQuery = "SELECT * FROM ftc_site_content WHERE published=1 AND parent=348 AND (lower(pagetitle) like '%".$pPhrase."%' OR lower(content) like '%".$pPhrase."%') ORDER BY publishedon DESC "; $pRes = $modx->query($pQuery); while($pRow = $pRes->fetch()){ ?><li><h2><?php echo stripslashes($pRow['pagetitle']);?></h2><p><?php echo substr(strip_tags(stripslashes($pRow['content'])),0,150);?> <a href="<?php echo $pRow['alias'];?>" style="color:#8C1E05;"> more »</a></p></li><?php $i++; }//while /* //searching in categories $pQuery = "SELECT n.news_id, n.insert_date, d.value as title, d2.value as content FROM ftc_news n INNER JOIN ftc_dictionary d ON d.record_id=n.news_id INNER JOIN ftc_dictionary d2 ON d2.record_id=n.news_id WHERE d.language_id=1 AND d.type='news' AND d.field='title' AND d2.type='news' AND d2.field='content' AND ( lower(d.value) like '%".$pPhrase."%' OR lower(d2.value) like '%".$pPhrase."%' )"; $pRes = $modx->query($pQuery); while($pRow = $pRes->fetch()){ ?><li><h2><?php echo stripslashes($pRow['title']);?></h2><p><?php echo substr(strip_tags(stripslashes($pRow['content'])),0,150);?> <a href="/<?php echo link_konwert($pRow['title']);?>-news<?php echo $pRow['news_id'];?>.html" style="color:#8C1E05;"> more »</a></p></li><?php $i++; }//while */ if($i==0){ ?><p><strong>No search results.</strong></p><?php } }else{ ?><p><strong>No search results.</strong></p><?php }//if ?> </ul>
This question has been answered by magzzs. See the first response.