我的表格没有填写我需要的所有数据。缺少一些列填充表单倍数。其中所有其余部分的雷诺所需的列都是空的。
在下一张图片中,您可以看到我在动态选择框中选择多个选项并提交时,只有当期望填充所有选定的列时才会填写第一列。
接下来是代码,其中选择框的值为多个。
if ($consulta !=0) {
}//
else{
echo "";
}
@$s1= $_POST['s1'];
if( is_array($s1)){
while (list ($key, $val) = each ($s1)) {
}
}//
else{
echo "";
}
/////////////////
@$s2= $_POST['s2'];
if( is_array($s2)){
?>
接下来是在html表中填充数据的代码。该行代码<td align=\"center\" bgcolor='FFFFFF'>
需要将以下结果与<?php echo "$key => $val1\n";?>
相关联:
<?php echo "$key => $val1\n";?>
0 => Renault 1 => Opel 2 => Mercedes 3 => Audi
缺少预期的输出。
雷诺
<form onsubmit=\"return validate();\" id=\"teste\" method=\"post\" action=\"teste.php\">
欧宝
<form onsubmit=\"return validate();\" id=\"teste\" method=\"post\" action=\"teste.php\">
梅赛德斯
<form onsubmit=\"return validate();\" id=\"teste\" method=\"post\" action=\"teste.php\">
奥迪
<form onsubmit=\"return validate();\" id=\"teste\" method=\"post\" action=\"teste.php\">
这是动态的,将从mysql数据库获取值,我可以选择我想要的。
所有表都填充了数据。静态和动态。
<table>
<tbody>
<tr>
<th>Parametro:</th>
<?php
while (list($key, $val1) = each ($s2)) {
?>
<th><?= htmlspecialchars($val1, ENT_HTML5 | ENT_COMPAT, 'UTF-8') ?></th>
<?php
echo "$key => $val1\n";
?>
<?php
}
?>
Parametro的值:
{
echo("<tr>
<td align=\"center\" bgcolor='FFFFFF'>$utilizador</td>
<td align=\"center\" bgcolor='FFFFFF'>
<form onsubmit=\"return validate();\" id=\"teste\" method=\"post\" action=\"teste.php\">
");
表格中的代码:
$con = mysqli_connect( "localhost","root","","teste" ); // ◄■ CONNECT TO DATABASE.
$dat_menuid = mysqli_query( $con,"SELECT * FROM menu WHERE menuId = '".$menuId."'" ) // ◄■ MENUIDs.
or die( mysqli_error($con) );
$con1 = mysqli_connect( "localhost","root","","teste" ); // ◄■ CONNECT TO DATABASE.
$idtem = mysqli_query($con1, "SELECT MAX(id_tem) as id_tem FROM tem")
or die( mysqli_error($con) );
// Print out result
while($row = $idtem->fetch_assoc())
$toEcho = $row["id_tem"];
//echo $toEcho;
$toEchosave = $toEcho + 1;
$_SESSION['myvar'] = $toEchosave;
$options = array( "0.00","0.05","0.10","0.15","0.20","0.25","0.30","0.35","0.40","0.45","0.50","0.55","0.60","0.65","0.70","0.75","0.80","0.85","0.90","0.95","1" ); // ◄■■ OPTIONS ARE STATIC (ALWAYS THE SAME).
while ( $row_menuid = mysqli_fetch_array( $dat_menuid ) ) // ◄■ DISPLAY <SELECT>s.
{ echo "<select class='sumselect' name='corp_resp&{$row_menuid['menuId']}&{$_SESSION['UtilizadorID']}&{$dateTime}&{$toEchosave}' multiple>"; // ◄■■ CORP_RESP&1,CORP_RESP&2.
foreach ($options as $opt)
echo "<option value='$opt'>$opt</option>\n";
echo "</select>\n";
} ?>
</form>
</td>
</tr>
<?php } ?>
<?php }
}
}
?>
<div id='sum'></div>
<br><br><br>
</tbody>
</table>
答案 0 :(得分:1)
按照此代码
<?php
$sql = "SELECT * FROM menu WHERE $id = menuIdPai ORDER BY menuId ";
$consulta = mysql_query($sql);
while ($mostrar = mysql_fetch_array($consulta)) {
$id = $mostrar['menuId'];
$utilizador = $mostrar['menuNome'];
?>
<tr>
<td align=\"center\" bgcolor='FFFFFF'>Test1</td>
<td align=\"center\" bgcolor='FFFFFF'>Test2</td>
<td align=\"center\" bgcolor='FFFFFF'>Test3</td>
<td align=\"center\" bgcolor='FFFFFF'>Test4</td>
</tr>
<?php
}
?>
这是主要格式,如果工作然后更新你的代码。你加2 td但你的主要4这样需要4 td
您的此标记未关闭
<td align="center" bgcolor='FFFFFF'>
<form onsubmit="return validate();" id="teste" method="post" action="teste.php">
在脚本中将其关闭
<div id='sum'></div>
<br><br><br>
</form>
</td>
</tr>
在结束循环之前移动此代码
foreach ($options as $opt)
echo "<option value='$opt'>$opt</option>\n";
echo "</select>\n";
} ?>
</form>
</td>
</tr>
<?php } ?>
<?php }
}
}
?>
<div id='sum'></div>
<br><br><br>
</tbody>
</table>