Using PHP and coreseek to build the job search function of the talent recruitment website
Talent recruitment websites play an important role in modern society, providing companies with a convenient way to find suitable employees. For job seekers, it is also very important to have an efficient job search function. This article will introduce how to use PHP and coreseek, an open source full-text search engine, to build a powerful job search function for a talent recruitment website.
First, we need to ensure that PHP and coreseek have been installed and configured. Next, we can start writing code.
<form method="GET" action="search.php"> <input type="text" name="keyword" placeholder="请输入关键词"> <input type="submit" value="搜索"> </form>
<?php $host = 'localhost'; $user = 'root'; $password = '123456'; $database = 'jobs'; $conn = mysqli_connect($host, $user, $password, $database); if (!$conn) { die("数据库连接失败: " . mysqli_connect_error()); } ?>
<?php // 获取用户输入的关键词 $keyword = $_GET['keyword']; // 构建查询语句 $query = "SELECT * FROM jobs WHERE MATCH(title) AGAINST('$keyword' IN BOOLEAN MODE)"; // 执行查询 $result = mysqli_query($conn, $query); ?>
<?php // 显示查询结果 if (mysqli_num_rows($result) > 0) { while ($row = mysqli_fetch_assoc($result)) { echo "<h2>{$row['title']}</h2>"; echo "<p>{$row['description']}</p>"; echo "<hr>"; } } else { echo "没有找到相关职位"; } // 关闭数据库连接 mysqli_close($conn); ?>
At this point, we have completed the basic implementation of the job search function. Through this function, users can enter keywords, and the system will search for matching positions in the database based on the keywords, and then display the results to the user.
It should be noted that in order to make job search more accurate and efficient, some optimization and configuration can be performed on coreseek. For example, you can weight searches or sort search results by relevance. These operations can be adjusted according to actual needs.
Summary: Using PHP and coreseek, we can quickly build a powerful job search function. This is very important for talent recruitment websites. It can improve user experience, provide more accurate job recommendations, and build a bridge between companies and job seekers. Hope this article can be helpful to you!
The above is the detailed content of Use PHP and coreseek to build the job search function of the talent recruitment website. For more information, please follow other related articles on the PHP Chinese website!