HTML 选择值到 PHP bp_has_members( 'search_terms=??)


HTML select value to PHP bp_has_members( 'search_terms=??)

尝试传递选择选项的值以更改 Bp 中成员的搜索词。

到目前为止,我可以使用"echo"打印值,但我无法根据我选择的选项设置搜索词。

打印选项工作正常:

<form method="post">
<select name="category">
  <option value="" selected>All</option>
  <option value="Design and print">Design and Print</option>
  <option value="Food & Drink">Food &amp Drink</option>
  <option value="market">Market</option>
    </select>
    <button type="submit" value="execute">SEARCH</button>     
</form>
<h5><?php echo $_POST['category']; ?></h5>

当我想在搜索词中将值作为字符串发送时,我无法找出正确的代码。

这是我有的:

<?php if ( bp_has_members( 'search_terms=$_POST['category']') ) : ?>        
<?php while ( bp_members() ) : bp_the_member(); ?> 

但是,搜索不起作用,例如我写"search_terms=食物和饮料"

更改此设置

bp_has_members( 'search_terms=$_POST['category']')

bp_has_members("search_terms={$_POST['category']}")

您应该收到语法错误。 下次尝试打开错误报告并调试代码。