我正在尝试在城市/州/邮政编码搜索中将伊利诺伊州替换为 IL;或者任何与此相关的州。我将状态存储为缩写。所以我需要将其包含在输入的搜索中。我正在尝试:
if(isset($_GET['search_loc'])&&isset($_GET['search_style'])) {
$search_loc = $_GET['search_loc'];
$search_style = $_GET['search_style'];
if(!empty($search_loc)||!empty($search_style)) {
/* HERE!!! */ $search_loc = str_replace('Illinois', 'IL', $search_loc); // ***Here!!!***
$query = "SELECT
name, street, city, state, zip_code, phone_number, style, description, time
FROM music_spots
WHERE CONCAT(city, ', ', state, ', ', zip_code) LIKE '%$search_loc%' // and so on...
但是,这不起作用。关于我如何做到这一点有什么想法吗?谢谢。
最佳答案
我强烈建议使用数据库存储和检索州名称。我可以向您保证,硬编码不是答案。
关于php - 尝试将 PHP 搜索中的完整州名替换为缩写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7452394/