core/api/modules/new_find/index.php

39 lines
1.3 KiB
PHP
Raw Normal View History

2022-12-11 13:55:49 +05:00
<?php
ini_set('display_errors', 0 );
2023-01-02 21:33:36 +05:00
$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'] );
}
/*
2022-12-11 13:55:49 +05:00
$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']);
2023-01-02 21:33:36 +05:00
}*/
$smarty->assign('title', "Поиск по сайту - " . $_POST['txt']);
2022-12-11 13:55:49 +05:00
$smarty->assign('list', $massiv);//получаем дочерние категории
?>