Skip to content

Commit

Permalink
Fix search.php
Browse files Browse the repository at this point in the history
  • Loading branch information
hoaquynhtim99 committed May 23, 2016
1 parent 32f3b75 commit 4719810
Showing 1 changed file with 28 additions and 24 deletions.
52 changes: 28 additions & 24 deletions modules/faq/search.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,31 +40,35 @@ function nv_faq_list_cats($module_data)

$list_cats = nv_faq_list_cats($m_values['module_data']);
$in = implode(",", array_keys($list_cats));
$num_items = 0;
$result_array = array();

$db->sqlreset()
->select('COUNT(*)')
->from(NV_PREFIXLANG . '_' . $m_values['module_data'])
->where("catid IN (" . $in . ")
AND
(" . nv_like_logic('question', $dbkeyword, $logic) . "
OR " . nv_like_logic('answer', $dbkeyword, $logic) . ")");

$num_items = $db->query($db->sql())->fetchColumn();

if ($num_items) {
$db->select('id,question, answer, catid')
->order('id DESC')
->limit($limit)
->offset(($page - 1) * $limit);

$tmp_re = $db->query($db->sql());
$link = NV_BASE_SITEURL . "index.php?" . NV_LANG_VARIABLE . "=" . NV_LANG_DATA . "&" . NV_NAME_VARIABLE . "=" . $m_values['module_name'] . '&' . NV_OP_VARIABLE . '=';
if (!empty($in)) {
$db->sqlreset()
->select('COUNT(*)')
->from(NV_PREFIXLANG . '_' . $m_values['module_data'])
->where("catid IN (" . $in . ")
AND
(" . nv_like_logic('question', $dbkeyword, $logic) . "
OR " . nv_like_logic('answer', $dbkeyword, $logic) . ")");

$num_items = $db->query($db->sql())->fetchColumn();

while (list($id, $question, $answer, $catid) = $tmp_re->fetch(3)) {
$result_array[] = array(
'link' => $link . $list_cats[$catid]['alias'] . '#faq' . $id,
'title' => BoldKeywordInStr($question, $key, $logic),
'content' => BoldKeywordInStr($answer, $key, $logic)
);
if ($num_items) {
$db->select('id, question, answer, catid')
->order('id DESC')
->limit($limit)
->offset(($page - 1) * $limit);

$tmp_re = $db->query($db->sql());
$link = NV_BASE_SITEURL . "index.php?" . NV_LANG_VARIABLE . "=" . NV_LANG_DATA . "&" . NV_NAME_VARIABLE . "=" . $m_values['module_name'] . '&' . NV_OP_VARIABLE . '=';

while (list($id, $question, $answer, $catid) = $tmp_re->fetch(3)) {
$result_array[] = array(
'link' => $link . $list_cats[$catid]['alias'] . '#faq' . $id,
'title' => BoldKeywordInStr($question, $key, $logic),
'content' => BoldKeywordInStr($answer, $key, $logic)
);
}
}
}

1 comment on commit 4719810

@sonbbui
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vẫn chưa fix được. chán quá. bạn xem lại được không?!

Please sign in to comment.