我有一个表格与我的产品,我正在尝试编写一个页面,从数据库中拉出具有某些颜色的手镯.所以这就是我现在所拥有的(在php中):
$query = "SELECT * FROM products WHERE (products.colors LIKE '%black%')";
Run Code Online (Sandbox Code Playgroud)
但我只想选择列"category"的值等于"bracelet"的行.
我尝试了一些不同的东西,但我不断收到警告和错误.谢谢你给我的任何帮助,谢谢!
我仍然是PHP的初学者,很抱歉,如果这是一个愚蠢的问题=)
我想要做的是在WordPress博客中,在我的RSS源中插入一个包含多个值("成分")的自定义字段.(我还有其他帖子不是食谱,这就是为什么标题"成分"和"说明"都在if语句中.)这是我到目前为止的整个代码:
<?php
function insertIngredients($content) {
/* get ingredients into variable $recipeStuff */
$recipeStuff =
if ($ingredients = get_post_custom_values('ingredients')) {
echo '<h3>Ingredients</h3><ul id="ingredients">';
foreach ( $ingredients as $key => $value ) {
echo '<li>';
echo $value;
echo '</li>';
}
echo '</ul><h3>Instructions</h3>';
}
/* add before content */
$content = $recipeStuff . $content;
return $content;
}
/* Do it! */
add_filter('the_excerpt_rss', 'insertIngredients');
add_filter('the_content_rss', 'insertIngredients');
?>
Run Code Online (Sandbox Code Playgroud)
但是得到一个"意外的IF"错误,所以我想我不能把所有内容放在$ recipeStuff变量中=)我只是想不出怎么把它放在那里.
(如果重要的话,IF语句就是我在页面本身的帖子中使用的,它完美无缺!)
非常感谢您的任何帮助!= d
UPDATE!
这就是我现在的代码:
function insertIngredients($content) {
/* test for presence of ingredients …Run Code Online (Sandbox Code Playgroud)