用php作循环呗
例子如下:<form action="",method="post">
<? for($a=1;%a<=50;%a++):
$b=bc;
if ($b=bc) $b=ab;
?><input type type=checkbox name=<?hehe{$a}?> value=<?$b?>>
……
……
<? endfor; ?>
例子如下:<form action="",method="post">
<? for($a=1;%a<=50;%a++):
$b=bc;
if ($b=bc) $b=ab;
?><input type type=checkbox name=<?hehe{$a}?> value=<?$b?>>
……
……
<? endfor; ?>
更正:
//2.php
<form action="add.php",method="post">
<table>
<?
$zhi="bc";
for($a=1;$a<=50;$a++):
if ($zhi=="bc")
$zhi="ab";
else $zhi="bc";
?>
<td>
<input type=checkbox name=<?echo "hehe{$a}"?> value=<?echo $zhi?>>111
</td>
<? endfor; ?>
<td><input type=submit vlaue="ok"></td>
</table>
//——————
//add.php
<?
for($a=1;$a<=50;$a++)
{ $dhehe= "hehe{$a}" ;
echo $dhehe."<br>";
echo ${$dhehe}."<br>";
}
?>
错了!
更正:
//2.php
<form action="add.php",method="post">
<table>
<?
$zhi="bc";
for($a=1;$a<=50;$a++):
if ($zhi=="bc")
$zhi="ab";
else $zhi="bc";
?>
<td>
<input type=checkbox name=<?echo "hehe{$a}"?> value=<?echo $zhi?>><?echo $zhi?>
</td>
<? endfor; ?>
<td><input type=submit vlaue="ok"></td>
</table>
//——————
//add.php
<?
for($a=1;$a<=50;$a++)
{ $dhehe= "hehe{$a}" ;
echo $dhehe."<br>";
echo ${$dhehe}."<br>";
}
?>
我这个程序是网上考试;在第一页里是多选题50道;name=t1[] ...name=t50[]
再数据库里有标准答案;我想把每个提交的多选题(数组)转变成字符串,好跟答案比较;
可是我用不想这样 $t1=join("",$t1)$t50=join("",$t50)
这样写50次,怎么实现??
//add.php
<?
for($a=1;$a<=50;$a++)
{ $dhehe= "hehe{$a}" ;
echo $dhehe."<br>";
echo ${$dhehe}."<br>";
$s.="${$dhehe}";
echo $s;
}
其中的$s就是你想要的字符串!