51 lines
1.7 KiB
PHP
51 lines
1.7 KiB
PHP
<?php
|
|
ini_set('display_errors', 0 );
|
|
function ekr ($text) { // ФУНКЦИЯ очистки кода
|
|
|
|
$old1 = array(" ");#Ищем вредное ">",, "<"
|
|
|
|
$new1 = array("%");#Меняем на полезное">", , "<"
|
|
|
|
$text = str_replace($old1, $new1, $text);#Собсно сама замена =)
|
|
|
|
return $text; }
|
|
|
|
|
|
|
|
|
|
$massiv=\DB::getAll(
|
|
"SELECT * FROM `tovar` WHERE (`id`=? OR `title` LIKE '%" . ekr( $_POST['txt'] ) . "%' OR `txt` LIKE '%" . ekr( $_POST['txt'] ) . "%' OR `artikul`=?) AND `status`=1",
|
|
array( $_POST['txt'], $_POST['txt'] ) );
|
|
|
|
|
|
//Получаем фото
|
|
for ( $i=0; $i <count( $massiv ); $i++ ) {
|
|
$massiv[$i]['img'] = \DB::getValue( "SELECT `filename` FROM `tovar_img` WHERE `tovar_id`=? LIMIT 1", $massiv[$i]['id'] );
|
|
$massiv[$i]['cena'] = \DB::getValue( "SELECT `cena` FROM `tovar_price_history` WHERE `tovar_id`=? ORDER BY `t` DESC LIMIT 1", $massiv[$i]['id'] );
|
|
|
|
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
$sql='SELECT `id`, `txt`, `tip` FROM `pages` WHERE `txt` LIKE "%' . $txt . '%" OR `artikul` LIKE "%' . $txt . '%" ORDER BY `tip`';
|
|
$massiv=$db->free_sql($sql);
|
|
function getTip($tip){
|
|
$arr['page']='Страница';
|
|
$arr['category']='Раздел';
|
|
$arr['tovar']='Товар';
|
|
$arr['tovar_cat']='Категория товара';
|
|
return $arr[$tip];
|
|
}
|
|
$count=count($massiv);
|
|
for ($i=0; $i<$count; $i++){
|
|
unset($a);
|
|
$a['page_id']=$massiv[$i]['id'];
|
|
$massiv[$i]['img']=$db->get_val('img', $a, 'fileName');
|
|
$massiv[$i]['tip']=getTip($massiv[$i]['tip']);
|
|
}*/
|
|
|
|
$smarty->assign('title', "Поиск по сайту - " . $_POST['txt']);
|
|
$smarty->assign('list', $massiv);//получаем дочерние категории
|
|
?>
|