есть поиск по магазину с 4 критериями.(по группе, названию, коду, номеру). все работают а "по группе" не работает.
Вот код html формы
<form method="post" action="/shop/search/">
<table>
<tr>
<div id="namegrup">
<td style=" vertical-align:middle; width: 173px; text-align: left; color: #5B90A5; font: bold 14px/15px Tahoma; "> Наименование группы</td> </div>
<td align="left" nowrap="nowrap">
<select class="chzn-select" name="search-type" value="grup">
<option value=""></option>
<option value="" selected>Выберите группу товара из списка</option>
<option value=""></option>
<option value="5">10.Двигатель</option>
<option value="24">11.Система питания</option>
<option value="2126">12.Система выпуска газа</option>
<option value="25">13.Система охлаждения</option>
<option value="31">16.Сцепление</option>
<option value="44">17.Коробка передач</option>
<option value="7221">18.Коробка раздаточная</option>
<option value="108">22.Валы карданные</option>
</select>
</td>
</tr>
</table>
<div id="search-shop">
<input type="text" size="20" name="search" id="input-search" <?if(isset($_SESSION['search'])) echo 'value="'.$_SESSION['search'].'"'?> placeholder="Поиск по каталогу" />
<div id="filter">
<input name="search_type" type="radio" value="by_name" id="by_name" <?if(!isset($_SESSION['search_type']) || $_SESSION['search_type']=='by_name') echo 'checked'?> /> <label for="by_name">:по названию</label>|
<input name="search_type" type="radio" value="by_code" id="by_code" <?if(isset($_SESSION['search_type']) && $_SESSION['search_type']=='by_code') echo 'checked'?>/> <label for="by_code">: по коду</label>|
<input name="search_type" type="radio" value="by_num" id="by_num" <?if(isset($_SESSION['search_type']) && $_SESSION['search_type']=='by_num') echo 'checked'?>/> <label for="by_num">:по каталожному номеру</label>
</div>
<input type="submit" id="submit" value="" />
</div>
</form>
А вот код php:
//Поиск
function search(){
$start_from = ($this->page-1)*$this->inpage;
if($_SESSION['search_type']=='grup')
return db()->rows("SELECT * FROM prefix_catalog WHERE cat LIKE '%".trim($_SESSION['search'])."%' ORDER BY title ASC LIMIT ".$start_from.",".$this->inpage);
elseif($_SESSION['search_type']=='by_code')
return db()->rows("SELECT * FROM prefix_catalog WHERE code='".trim($_SESSION['search'])."' ORDER BY title ASC LIMIT ".$start_from.",".$this->inpage);
elseif($_SESSION['search_type']=='by_name')
return db()->rows("SELECT * FROM prefix_catalog WHERE title LIKE '%".trim($_SESSION['search'])."%' OR synonyms LIKE '%".trim($_SESSION['search'])."%' ORDER BY title ASC LIMIT ".$start_from.",".$this->inpage);
else
return db()->rows("SELECT * FROM prefix_catalog WHERE title LIKE '%".trim($_SESSION['search'])."%' ORDER BY title ASC LIMIT ".$start_from.",".$this->inpage);
}
//Вычисляем сколько всего страниц поиска
function search_total_pages(){
if($_SESSION['search_type']=='grup')
$result = db()->row("SELECT COUNT(*) FROM prefix_catalog WHERE cat LIKE '%".trim($_SESSION['search'])."%'");
elseif($_SESSION['search_type']=='by_code')
$result = db()->row("SELECT COUNT(*) FROM prefix_catalog WHERE code='".trim($_SESSION['search']));
elseif($_SESSION['search_type']=='by_name')
$result = db()->row("SELECT COUNT(*) FROM prefix_catalog WHERE title LIKE '%".trim($_SESSION['search'])."%' OR synonyms LIKE '%".trim($_SESSION['search'])."%'");
else
$result = db()->row("SELECT COUNT(*) FROM prefix_catalog WHERE title LIKE '%".trim($_SESSION['search'])."%'");
return ceil($result/$this->inpage);
}