我试图在单个 where 子句上为多个条件设置回显...如果找到此值回显某些内容...如果找到另一个值回显某些内容...我的代码当前一直回显表中的所有数据它只应该根据特定字段中存储的值来回显一组特定的数据......
<?php
$query = mysql_query("SELECT *
FROM tblfoodoptions JOIN tblhealthconditionfoods
ON tblfoodoptions.FoodID = tblhealthconditionfoods.FoodID, tblhealthcondition
WHERE tblhealthconditionfoods.HealthconditionID = tblHealthcondition.HealthconditionID
AND tblhealthcondition.Healthcondition IN ( 'Diabetes Type1' OR 'Diabetes Type2' OR 'General Health' OR 'Pregnant' OR 'Anemia' OR 'High Cholesterol')");
{
echo "<table width='100%' border='4'>
<caption>Your Food Options</caption>
<thead>
<tr>
<th>FoodName</th>
<th>Serving_Size</th>
<th>Calories</th>
<th>Cholestrol</th>
<th>Sodium</th>
<th>Protein</th>
<th>Total_Carbohydrates</th>
<th>Total_Fat</th>
</tr>
</thead>
<tbody>";
while($row = mysql_fetch_array($query))
{
echo "<tr>";
echo "<td>".$row['FoodName']."</td>";
echo "<td>".$row['Serving_Size']."</td>";
echo "<td>".$row['Calories']."</td>";
echo "<td>".$row['Cholesterol']."</td>";
echo "<td>".$row['Sodium']."</td>";
echo "<td>".$row['Protein']."</td>";
echo "<td>".$row['Total_Carbohydrates']."</td>";
echo "<td>".$row['Total_Fat']."</td>";
echo "</tr>";
}
echo "</tbody></table>";
}
?>