php - How to echo multiple results from database -
how echo multiple results. displays recipe names want able echo steps database well. field in database step 1.
<?php if (isset($_post['search'])) { $ingredient1 = $_post['dropdown1']; $ingredient2 = $_post['dropdown2']; $ingredient3 = $_post['dropdown3']; $recipes = mysql_query(" select distinct `name` `recipe` r inner join `recipe_ingredients` ri on r.id = ri.recipe_id ri.ingredient_id in (".$ingredient1.",".$ingredient2.",".$ingredient3.") "); echo '<section id="results">'; while ($recipe = mysql_fetch_assoc($recipes)) { echo $recipe['name'].'<br />'; } } echo '</section>'; ?>
this threw error. : php parse error: syntax error, unexpected ',', expecting ']' in \pdc3\sites\c\cupboard2stomach.com\public_html\php\get.php on line 97
echo $recipe['name'].'<br />'; echo $recipe['step1'].'<br />';
no error doesn't display results.
echo $recipe['name','step1'].'<br />';
recipe table
echo '<section id="results">'; while ($recipe = mysql_fetch_assoc($recipes)) { echo $recipe['name'].'<br />'; echo $recipe['step1'].':','<br />'; echo $recipe['step2'].':','<br />'; echo $recipe['step3'].':','<br />'; } } echo '</section>';
these results back
select r.`name`, r.`step1` `recipe` r inner join `recipe_ingredients` ri on r.id = ri.recipe_id ri.ingredient_id in ('".$ingredient1."', '".$ingredient2."', '".$ingredient3."') group r.`name`
Comments
Post a Comment