set('box_top', box_top('Search')); $template->set('box_bottom', box_bottom()); $basic_search = $db->rem_special_chars($_REQUEST['basic_search']); $basic_search = optimize_search_string($basic_search); $search_array = explode(" ", $_REQUEST['basic_search']); $start = $_REQUEST['start']?$_REQUEST['start']:0; $limit = 20; ## search /*$db->query('ALTER TABLE ' . DB_PREFIX . 'ifc_countries ENGINE = MYISAM'); $db->query('ALTER TABLE ' . DB_PREFIX . 'glossary ENGINE = MYISAM'); $db->query('ALTER TABLE ' . DB_PREFIX . 'news_posts ENGINE = MYISAM'); $db->query('ALTER TABLE ' . DB_PREFIX . 'blog_posts ENGINE = MYISAM'); $db->query('ALTER TABLE ' . DB_PREFIX . 'articles_posts ENGINE = MYISAM');*/ ## search in IFC's $query = "SELECT '' as gui, name, capital as description, 'IFC' as found, 'ifcs.php' as url FROM " . DB_PREFIX . "ifc_countries WHERE (MATCH (name, capital) AGAINST ('" . $basic_search . "*' IN BOOLEAN MODE)) "; ## search in glossary $query .= "UNION SELECT '' as gui, name, description, 'Glossary' as found, 'glossary.php' as url FROM " . DB_PREFIX . "glossary WHERE (MATCH (name, description) AGAINST ('" . $basic_search . "*' IN BOOLEAN MODE)) GROUP BY name "; ## search in news $query .= "UNION SELECT post_name as gui, post_title as name, post_content as description, 'FinWire - News' as found, 'news' as url FROM " . DB_PREFIX . "news_posts WHERE (MATCH (post_title, post_content) AGAINST ('" . $basic_search . "*' IN BOOLEAN MODE)) AND post_type = 'post' AND post_status = 'publish' GROUP BY post_title "; ## search in articles $query .= "UNION SELECT post_name as gui, post_title as name, post_content as description, 'Financial Articles' as found, 'articles' as url FROM " . DB_PREFIX . "articles_posts WHERE (MATCH (post_title, post_content) AGAINST ('" . $basic_search . "*' IN BOOLEAN MODE)) AND post_type = 'post' AND post_status = 'publish' GROUP BY post_title "; ## search in blog $query .= "UNION SELECT post_name as gui, post_title as name, post_content as description, 'Financial Blog' as found, 'blog' as url FROM " . DB_PREFIX . "blog_posts WHERE (MATCH (post_title, post_content) AGAINST ('" . $basic_search . "*' IN BOOLEAN MODE)) AND post_type = 'post' AND post_status = 'publish' GROUP BY post_title " ; //g $nb_items = $db->get_sql_number($query); if($nb_items>0) { $query = $query . " LIMIT " . $start . ", " . $limit; $additional_vars = '&basic_search=' . $_REQUEST['basic_search']; $pagination = paginate($start, $limit, $nb_items, 'search.php', $additional_vars); //g $template->set('pagination', $pagination); $query = $db->query($query); while ($record = $db->fetch_array($query)) { if($record['url']=="news") $url ="news/".$record['gui']."/"; elseif($record['url']=="world") $url ="world/".$record['gui']."/"; elseif($record['url']=="blog") $url ="blog/".$record['gui']."/"; elseif($record['url']=="articles") $url ="articles/".$record['gui']."/"; else $url = $record['url']; $search_options_title .= ' '. $record['name'].' '. $record['found'].' '. GetFormatShortTitle($db->add_special_chars($record['description'])).' '; } } else { $search_options_title = "No results. Try Again"; } $template->set('search_options_title', $search_options_title); $template_output .= $template->process('search.tpl.php'); include_once ('global_footer.php'); echo $template_output; ?>