我希望这是一个简单的问题,我找不到任何完整问题的答案。
我有一个从MySQL返回的数组,看起来像这样
mysql> select c.comment, d.name, m.ounces from drink d
inner join mix m on m.drinkID = d.ID
inner join cocktail c on m.cocktailID = c.id
where c.id =5;
+----------------------+------------+--------+
| comment | name | ounces |
+----------------------+------------+--------+
| Long Island Iced Tea | Vodka | 0.75 |
| Long Island Iced Tea | Gin | 0.75 |
| Long Island Iced Tea | Rum | 0.75 |
| Long Island Iced Tea | Tequila | 0.75 |
| Long Island Iced Tea | Sour Mix | 2.00 |
| Long Island Iced Tea | Cola | 1.00 |
| Long Island Iced Tea | Triple Sec | 1.00 |
+----------------------+------------+--------+
我正在尝试让PHP生成一个类似于下面的无序列表。
<div class="jumbotron">
<h2>
Long Island
</h2>
<p>
<ul>
<li>0.5 oz Vodka</li>
<li>0.5 oz Rum</li>
<li>0.5 oz Gin</li>
<li>0.5 oz Tequila</li>
<li>0.5 oz Triple Sec</li>
<li>1 oz Sweet and Sour Mix</li>
<li>1 oz cola </li>
</ul>
我正在尝试这个:
$ingredient = "select
c.comment, d.name, m.ounces
from drink d
inner join mix m on m.drinkID = d.ID
inner join cocktail c on m.cocktailID = c.id
where c.id = 4";
//print($ingredient);
$result = mysql_query($ingredient);
<?php foreach($result as $results): ?>
<li><? echo $results ?></li>
<?php endforeach; ?>
从这里:StackOverflow但无法弄清楚为什么我一直从PHP接收HTTP 500错误。
任何帮助或指导都将不胜感激!
谢谢!
答案 0 :(得分:0)
您正在使用最有可能被禁用的短标签。试试这个
WHERE
答案 1 :(得分:-1)
{"html_attributions": [],
"result": {
"address_components": [
{
"long_name": "1",
"short_name": "1",
"types": [
"street_number"
]
},
{
"long_name": "East 161st Street",
"short_name": "E 161st St",
"types": [
"route"
]
},
{
"long_name": "Concourse",
"short_name": "Concourse",
"types": [
"neighborhood",
"political"
]
},
{
"long_name": "Bronx",
"short_name": "Bronx",
"types": [
"sublocality_level_1",
"sublocality",
"political"
]
},
{
"long_name": "Bronx County",
"short_name": "Bronx County",
"types": [
"administrative_area_level_2",
"political"
]
},
返回一组行,而不是单个行
mysql_query()