任何想法为什么这不会打印出来
修改 php 似乎无法打印出我想要的值
有什么想法吗?
谢谢
<form action="revision.php" method="GET">
<input type=“text” name=“number[]”/>
<input type=“text” name=“number[]”/>
<input type=“text” name=“number[]”/>
<input type=“text” name=“number[]”/>
<input type=“text” name=“number[]”/>
<input type="Submit" name="Calcuate"/>
</form>
<?php
if(isset($_GET['number'])){
$amount = count($number);
for($i=0; $i < $amount; $i++){
echo $number[$i];
}
}
?>
Revising for php and cant seem to get this to print the values out that i want
Any ideas?
Thanks
<form action="revision.php" method="GET">
<input type=“text” name=“number[]”/>
<input type=“text” name=“number[]”/>
<input type=“text” name=“number[]”/>
<input type=“text” name=“number[]”/>
<input type=“text” name=“number[]”/>
<input type="Submit" name="Calcuate"/>
</form>
<?php
if(isset($_GET['number'])){
$amount = count($number);
for($i=0; $i < $amount; $i++){
echo $number[$i];
}
}
?>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
编辑:我的答案是完全错误的。请参阅下面评论中的@rmarimon。
文本字段无法映射到数组。您必须将它们命名为难看的名称,例如“number1”、“number2”等,然后使用 $_GET['number1'] + ... 将它们相加。
EDIT: My answer is completely wrong. See @rmarimon in comments below.
Text fields can't be mapped to an array. You'll have to name them something ugly like "number1", "number2", etc and add them up with $_GET['number1'] + ...
将形式更改为此。
为此必须使用多部分标记,
您还需要使用它来进行文件上传
和打印,
因为数组可以是 number[1] ->数量[3]
Change form to this.
The multipart tag must be used for this
you also need this for file uploads
and for printing use this
because the array can be number[1] -> number[3]
它不在您的代码中,但您是否有
您正在做的事情是正确的方法。这与另一个问题类似。
It is not in your code but do you have
What you are doing is the correct way. This is similar to this other question.
在我看来,您应该在代码中更改一些内容,首先是字段的名称,您尝试将它们命名为 number[0]、number[1]、number[2]但它不会那样工作,请尝试以不同的方式命名它们,或者尝试创建一个 FOR cicle 来创建具有这些自定义名称的字段。其次,为了将 $_GET 变量中的数组保存到 $number 变量中,您需要这样的内容:
希望这会有所帮助,如果您仍然遇到问题,请尝试发布或描述上下文以及您的想法形式和数组。
The way I see it, there's a couple things you should change in your code, first, the names of the fields, you're trying to name them number[0], number[1], number[2] from the looks of it but it won't work that way, try naming them differenty or try to make a FOR cicle to create the fields with those custom names. Second, in order to save the array coming in the $_GET variable into the $number variable you need something like this:
Hope this helps, if you're still having problems try posting or describing the context and what you have in mind for the form and the array.
我认为您的代码的实际问题是引号“是错误的,您使用的是“和”而不是“。更换它们,一切都会正常。
I think the actual problem with your code is that the quotation marks " are wrong you are using “ and ” instead of ". Replace those and everything will work.