我想知道如何将用户选择的$row['id']
保存到一个准备存储到我的DB的变量中。
我能解决这类问题吗?
<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>
如果只想将值保存到数据库中,则可以使用全局变量$_poster
as
在同一个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'];
}
?>