39 lines
1.3 KiB
PHP
39 lines
1.3 KiB
PHP
<?php
|
|
ini_set('display_errors', 0 );
|
|
|
|
$massiv=\DB::getAll(
|
|
"SELECT * FROM `tovar` WHERE (`id`=? OR `title` LIKE '%" . $_POST['txt'] . "%' OR `txt` LIKE '%" . $_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);//получаем дочерние категории
|
|
?>
|