我想知道如何将$row['id']用户选择的内容保存到准备存储到我的数据库的变量中。我可以解决这样的问题吗?<form action="shippingmethod.php" method="post" role="form" class="send-it-test"> <select class="form-control search-slt" name="selezione_sede"> <?php $sql = "SELECT id,city,address FROM sedi ORDER BY city"; $ris = mysqli_query($db,$sql); while($row = mysqli_fetch_array($ris)){ echo "<option value='" . $row['id']."'>" . $row['city'] ." ,". $row['address']."</option>"; } ?> </select> <div class="text-center"> <button type="submit">Send</button> </div></form>
1 回答
猛跑小猪
TA贡献1858条经验 获得超8个赞
如果您只想将值保存到数据库中,您可以使用全局变量$_POST作为
在同一个 php 文件中。
<form action="test.php" method="post" role="form" class="send-it-test">
<select class="form-control search-slt" name="selezione_sede">
<?php
$sql = "SELECT id,city,address FROM sedi ORDER BY city";
$ris = mysqli_query($db,$sql);
while($row = mysqli_fetch_array($ris)){
echo "<option value='" . $row['id']."'>" . $row['city'] ." ,". $row['address']."</option>";
}
?>
</select>
<div class="text-center">
<button type="submit" name="submit">Send</button>
</div>
</form>
<?php
if(isset($_POST['submit'])){
$value = $_POST['selezione_sede'];
}
?>
- 1 回答
- 0 关注
- 141 浏览
添加回答
举报
0/150
提交
取消