简体   繁体   English

HTML选择值转换为PHP bp_has_members('search_terms = ??)

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

trying to pass the values of a select option to change the search term of members in Bp. 尝试传递选择选项的值以更改Bp中成员的搜索词。

so far I can print the value with "echo" but i cannot set the search term depending on my option selected. 到目前为止,我可以使用“ echo”打印值,但是我无法根据选择的选项设置搜索项。

Printing the option works fine: 打印选项可以正常工作:

<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>

When I want to send the value as a string in the search term I cannot figure out the right code. 当我想在搜索词中将值作为字符串发送时,我无法找出正确的代码。

here what I have: 这是我所拥有的:

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

however, the search not work as if i write 'search_terms=Food & Drink' for example 但是,搜索无法正常工作,就像我写“ search_terms = Food&Drink”一样

change this 改变这个

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

to

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

You should have been getting a syntax error. 您应该已经收到语法错误。 try turning error reporting on and debugging your code next time. 尝试打开错误报告并在下次调试代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM