I have a form like this:
我有一个这样的表格:
</span><select data-role=slider name="ndata[0]" /><option value=0> E </option><option value=1> F </option></select>
<span>1b: </span><select data-role=slider name="ndata[1]" /><option value=0> E </option><option value=1> F </option></select>
<span>1c: </span><select data-role=slider name="ndata[2]" /><option value=0> E </option><option value=1> F </option></select>
Then, I want to insert every data to a looping process in php file. This is my script:
然后,我想将每个数据插入到php文件中的循环过程中。这是我的脚本:
<?php
foreach( $_GET['ndata'] as $ch => $data ) {
$flag = 0;
if($data[$flag] == 0){
echo "<li><a href=\"img2.php\" target=\"blank\">Sektor ".($flag + 1)."</a></li>\n";}
$flag++;}
?>
I've tried that and I get some errors. Do you have any idea?
我试过了,我得到了一些错误。你有什么主意吗?
1 个解决方案
#1
0
I assume, you want to print something like that if "E" is selected.
我假设,如果选择“E”,你想打印类似的东西。
Sektor 1
Sektor 2
if so you should use this code segment:
如果是这样,您应该使用此代码段:
foreach( $_GET['ndata'] as $key => $value ) {
if($value == 0) {
echo "<li><a href=\"img2.php\" target=\"blank\">Sektor ".($key + 1)."</a></li>\n";
}
}
because, $_GET['ndata'] will return such array:
因为,$ _GET ['ndata']会返回这样的数组:
array(3) {
[0]=> string(1) "0"
[1]=> string(1) "1"
[2]=> string(1) "0"
}
so above code segment helps you to print correct sector number ($key + 1
) by looking $value
.
因此上面的代码段可以帮助您通过查看$ value来打印正确的扇区号($ key + 1)。
if this is not the case, can you write errors you got in detail.
如果不是这样的话,你能否写下你得到的错误。
#1
0
I assume, you want to print something like that if "E" is selected.
我假设,如果选择“E”,你想打印类似的东西。
Sektor 1
Sektor 2
if so you should use this code segment:
如果是这样,您应该使用此代码段:
foreach( $_GET['ndata'] as $key => $value ) {
if($value == 0) {
echo "<li><a href=\"img2.php\" target=\"blank\">Sektor ".($key + 1)."</a></li>\n";
}
}
because, $_GET['ndata'] will return such array:
因为,$ _GET ['ndata']会返回这样的数组:
array(3) {
[0]=> string(1) "0"
[1]=> string(1) "1"
[2]=> string(1) "0"
}
so above code segment helps you to print correct sector number ($key + 1
) by looking $value
.
因此上面的代码段可以帮助您通过查看$ value来打印正确的扇区号($ key + 1)。
if this is not the case, can you write errors you got in detail.
如果不是这样的话,你能否写下你得到的错误。