我正在尝试创建一些代码来编写mysql中的组件列表 像这样的东西
@EnableJpaRepositories
并在下拉列表中将其设为此
decod - 1,2,3,4,5
我试过这个:
decod (dorplist) 1
2
3
4
5
并确实将其输出为XML
但我不知道怎么做!我像这样输出
<?php
$mysqli = mysqli_connect("host", "username", "password", "name");
$result = mysqli_query($mysqli, 'SELECT * FROM componnets') or die(mysqli_error(mysqli));
while ($row = mysqli_fetch_array($result)) {
$org = str_replace("," , "'>", $row['fill']."");
$replace = str_replace("," , "
".$org."</option><option value='", $row['fill']."'>");
echo "<input type='hidden' name='compo' value='".$row['compon']."'>".$row['compon']."";
echo "<select name='fill'>";
echo "<option value='".$replace."'>".$replace."</option>";
echo "</select>";
}
// Free result set
mysqli_free_result($result);
/* close connection */
$mysqli->close();
?>
答案 0 :(得分:1)
首先在<select>
循环之外创建while
。然后遍历行以添加元素。
我不确定您在str_replace
来电时要完成的工作,所以我将其删除了。
这样的事情可能会让你开始朝着正确的方向前进:
<?php
$result = mysqli_query($mysqli, 'SELECT * FROM componnets') or die(mysqli_error(mysqli));
echo "<select name='fill'>";
echo "<input type='hidden' name='compo' value='".$row['compon']."'>".$row['compon']."";
while ($row = mysqli_fetch_array($result)) {
echo "<option value='".$row['fill']."'>".$row['fill']."</option>";
}
echo "</select>";
mysqli_free_result($result);
$mysqli->close();
?>