PHP / MYSQL: 如何使用Normal Where子句并搜索Where子句用于Mysqli查询
$search = $_POST['cloud_edge'];
$cloud_edge = 1;
$network_countries = $wpdb->get_results('SELECT * From media_networks WHERE
cloud_edge = "'.$cloud_edge.'" AND capital_city LIKE "'%$search%'" ORDER by
capital_city ');
答案 0 :(得分:0)
您缺少第二个变量的连接。
<?php
$search = $_POST['cloud_edge'];
$cloud_edge = 1;
$network_countries = $wpdb->get_results('SELECT * From media_networks WHERE
cloud_edge = "'.$cloud_edge.'" AND capital_city LIKE "%'.$search.'%" ORDER by
capital_city ');
答案 1 :(得分:0)
您需要正确连接搜索变量
LIKE "%'.$search.'%"
此外,您无法使用变量添加%
,但不会返回结果。试试以下
$network_countries = $wpdb->get_results('SELECT * From media_networks WHERE
cloud_edge = "'.$cloud_edge.'" AND capital_city LIKE "%'.$search.'%" ORDER by
capital_city ');
答案 2 :(得分:0)
addPrimitive