为什么在此代码上回显不正确的值?
当你将数据填充到这样的输入
时http://image.ohozaa.com/i/gee/blkvz4.jpg
它会回应
111
8
333
444
8
666
777
8
999
为什么不回声
111
222
333
444
555
666
777
888
999
我该怎么办?
............................................... .................................................. .................................................. .........
这是完整的代码
<?PHP
include("connect.php");
?>
<div>
TEST NUMBER<br>
<form method="post" enctype="multipart/form-data">
<div>
<p>
<label> <input type="text" name="number[]"> Number By <input type="text" name="price"> / <input type="text" name="time[]">
</label>
</p>
<p>
<label> <input type="text" name="number[]"> Number By <input type="text" name="price"> / <input type="text" name="time[]">
</label>
</p>
<p>
<label> <input type="text" name="number[]"> Number By <input type="text" name="price"> / <input type="text" name="time[]">
</label>
</p>
<input type="submit" name="submit" value="Next">
</div>
</div>
<?php
if(isset($_POST["submit"]))
{
$number = '';
$price = '';
$time = '';
for($i=0;$i<count($_POST["number"]);$i++)
{
$number = mysql_real_escape_string($_POST['number'][$i]);
$price = mysql_real_escape_string(str_replace(',', '', $_POST['price'][$i]));
$time = mysql_real_escape_string($_POST['time'][$i]);
echo $number;
echo "<br>";
echo $price;
echo "<br>";
echo $time;
echo "<br>";
}
}
?>
答案 0 :(得分:4)
此字段的名称错误:
<input type="text" name="price">
应该是
<input type="text" name="price[]">
答案 1 :(得分:0)
你应该使用
<input type="text" name="price[]">
而不是
<input type="text" name="price">