输入类型=提交不返回任何东西
input type=submit not returning anything
团队,你能帮我解决这个问题吗?我正在尝试从表单中获取值以更改 mysql 上的这些值。这是一个需要值的销售操作,这将被放入数据库中。
我有一个复选框,允许用户 select 根据这个 selection 他想要出售哪些对象我正在创建一个新的 table 波纹管对象 select ed 和 POST 值的方法。然而,这并没有完全满足我的需要,我不知道如何将每个值与正确的对象相关联。你能帮忙吗 ?这是我坚持的部分,更具体地说是在第二个 isset 上:
if(isset($_POST['publicar'])){//to run PHP script on submit
if(!empty($_POST['check_list'])){
echo "<tr><td>Sites a Publicar</td><td>Valor</td></tr>";
foreach($_POST['check_list'] as $selected){
echo"<tr><td>".$selected."</td><td><input type=number name=valor_site[]></td></tr>";
$_SESSION['lista_public[]']=$selected;
}
echo"<tr><td><input type='submit' name='submit_valor' value='Submit' /></td></tr>";
}
}
if(isset($_POST['submit_valor'])){
if(!empty($_POST['valor_site'])){
foreach($_POST['valor_site'] as $valor_site){
echo $selected." tem valor ".$valor_site;
}
}
}
问题出在这一行:
$_SESSION['lista_public[]']=$selected;
这每次都会覆盖存储在$_SESSION['lista_public[]']
中的值。我的建议是:
$_SESSION['lista_public'] = array();
if(isset($_POST['publicar'])){//to run PHP script on submit
if(!empty($_POST['check_list'])){
echo "<tr><td>Sites a Publicar</td><td>Valor</td></tr>";
foreach($_POST['check_list'] as $selected){
echo"<tr><td>".$selected."</td><td><input type=number name=valor_site[]></td></tr>";
$_SESSION['lista_public'][] = $selected;
}
echo"<tr><td><input type='submit' name='submit_valor' value='Submit' /></td></tr>";
}
}
if(isset($_POST['submit_valor'])){
if(!empty($_POST['valor_site'])){
$i = 0;
foreach($_POST['valor_site'] as $valor_site){
echo $_SESSION['lista_public'][$i++]." tem valor ".$valor_site;
}
}
}
使用数组
$temp = array()
if(isset($_POST['publicar'])){//to run PHP script on submit
if(!empty($_POST['check_list'])){
echo "<tr><td>Sites a Publicar</td><td>Valor</td></tr>";
foreach($_POST['check_list'] as $selected){
echo"<tr><td>".$selected."</td><td><input type=number name=valor_site[]></td></tr>";
$temp[]=$selected;
}
$_SESSION['lista_public'] = $temp;
echo"<tr><td><input type='submit' name='submit_valor' value='Submit' /></td></tr>";
}
}
if(isset($_POST['submit_valor'])){
if(!empty($_POST['valor_site'])){
$i = 0;
$temp = $_SESSION['lista_public'];
foreach($_POST['valor_site'] as $valor_site){
echo $temp[$i++]." tem valor ".$valor_site;
}
}
团队,你能帮我解决这个问题吗?我正在尝试从表单中获取值以更改 mysql 上的这些值。这是一个需要值的销售操作,这将被放入数据库中。 我有一个复选框,允许用户 select 根据这个 selection 他想要出售哪些对象我正在创建一个新的 table 波纹管对象 select ed 和 POST 值的方法。然而,这并没有完全满足我的需要,我不知道如何将每个值与正确的对象相关联。你能帮忙吗 ?这是我坚持的部分,更具体地说是在第二个 isset 上:
if(isset($_POST['publicar'])){//to run PHP script on submit
if(!empty($_POST['check_list'])){
echo "<tr><td>Sites a Publicar</td><td>Valor</td></tr>";
foreach($_POST['check_list'] as $selected){
echo"<tr><td>".$selected."</td><td><input type=number name=valor_site[]></td></tr>";
$_SESSION['lista_public[]']=$selected;
}
echo"<tr><td><input type='submit' name='submit_valor' value='Submit' /></td></tr>";
}
}
if(isset($_POST['submit_valor'])){
if(!empty($_POST['valor_site'])){
foreach($_POST['valor_site'] as $valor_site){
echo $selected." tem valor ".$valor_site;
}
}
}
问题出在这一行:
$_SESSION['lista_public[]']=$selected;
这每次都会覆盖存储在$_SESSION['lista_public[]']
中的值。我的建议是:
$_SESSION['lista_public'] = array();
if(isset($_POST['publicar'])){//to run PHP script on submit
if(!empty($_POST['check_list'])){
echo "<tr><td>Sites a Publicar</td><td>Valor</td></tr>";
foreach($_POST['check_list'] as $selected){
echo"<tr><td>".$selected."</td><td><input type=number name=valor_site[]></td></tr>";
$_SESSION['lista_public'][] = $selected;
}
echo"<tr><td><input type='submit' name='submit_valor' value='Submit' /></td></tr>";
}
}
if(isset($_POST['submit_valor'])){
if(!empty($_POST['valor_site'])){
$i = 0;
foreach($_POST['valor_site'] as $valor_site){
echo $_SESSION['lista_public'][$i++]." tem valor ".$valor_site;
}
}
}
使用数组
$temp = array()
if(isset($_POST['publicar'])){//to run PHP script on submit
if(!empty($_POST['check_list'])){
echo "<tr><td>Sites a Publicar</td><td>Valor</td></tr>";
foreach($_POST['check_list'] as $selected){
echo"<tr><td>".$selected."</td><td><input type=number name=valor_site[]></td></tr>";
$temp[]=$selected;
}
$_SESSION['lista_public'] = $temp;
echo"<tr><td><input type='submit' name='submit_valor' value='Submit' /></td></tr>";
}
}
if(isset($_POST['submit_valor'])){
if(!empty($_POST['valor_site'])){
$i = 0;
$temp = $_SESSION['lista_public'];
foreach($_POST['valor_site'] as $valor_site){
echo $temp[$i++]." tem valor ".$valor_site;
}
}