我有一个表单,它将输入值捕获为会话参数。一个输入特别是具有5种不同选项(手机运营商)的选择。我希望表单提交id(carrier_id),但在确认页面上回显相关值(carrier_name)。
这样的事情:
<form action="confirm_form.php" role="form">
<div class="form-group">
<label for="carrier>Select Carrier</label>
<select type="text" class="form-control" name="carrier" value="">
<?php
$q = "SELECT * FROM carriers";
$carriers = mysqli_query($con, $q);
while($row = mysqli_fetch_assoc($carriers)) {
$carrier_id = $row['car_id'];
$carrier_name = $row['car_name'];
echo "<option value='$carrier_id'>$carrier_name</option>";
}
?>
</select>
</div>
<button type="submit" value="submit" name="submit">Add customer</button>
</form>
$carrier = mysqli_real_escape_string($con, $_SESSION['carrier']);
confirm_form.php页面应该回显载波名称但是当我尝试它时输出carrier_id或空白。请帮忙。
我还假设这个快速概述中的其他因素我没有输入。 (我已经有了session_start();为了一个而调用了
答案 0 :(得分:0)
主要表单和设置方法帖子
<?php
session_start();
if(isset($_POST['carrier'])){
$_SESSION['carrier']=$_POST['carrier'];
$carrier = mysqli_real_escape_string($con, $_SESSION['carrier']);
//Then query here.........
echo $_SESSION['carrier'];
}
?>
<强> confirm_form.php 强>
D <- data.frame(
c("pr1","pr2","pr3","pr4"),
c(0.1,0.0,0.3,0.2),
c(0.2,0.1,0.3,0.4),
c(0.2,0.1,0.3,0.4)
)
colnames(D) <- c("id", 1:(ncol(D)-1))
library(reshape2) # for melt function
D2 <- melt(D, value.name="id")