<?php
if($action == '')
{
echo '<div id="panelTitle">新增数据</div><br />';
echo '<form name="formEditItem" method="post" action="addtest.php?action=add">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#B0C5FF">
<tr>
<th bgColor=#cedcff height=20 align="left">&nbsp;&nbsp;Item</th>
<th bgColor=#cedcff height=20 align="left">&nbsp;&nbsp;Value</th>
</tr>'; for ($i=1; $i < 17; $i++)
{
echo '<tr class="cells" onmouseover="this.className=\'cells2\'" onmouseout="this.className=\'cells\'">';
echo '<td width=200 align="left">'."Label_2D_Code".'</td>';
echo '<td align="left"> <input type="text" value="'.$var.'" name="'.$i.'" size="80" onMouseOver="this.focus()" /></td>';
echo '</tr>';
}
echo '</table><br />';
echo '<input name="btnEditOK" type="submit" title="Submit" class="btnbig" value="提交" onclick="javascript:submit();" onmouseover="this.className=\'btnbig_over\'" onMouseOut="this.className=\'btnbig\'" onMouseDown="this.className=\'btnbig_down\'" onMouseUp="this.className=\'btnbig\'" />
  <input name="btnEditReset" type="reset" title="Drop and Reset" class="btnbig" value="重置"  onmouseover="this.className=\'btnbig_over\'" onMouseOut="this.className=\'btnbig\'" onMouseDown="this.className=\'btnbig_down\'" onMouseUp="this.className=\'btnbig\'" />';
}
?>
print_r($_POST);
能否在输出的时候,判断有重复的值并提示警告?

解决方案 »

  1.   

    你说的是for循环里面的input框的值?
      

  2.   

    请注意这样的事实$ar = array(1,2,3,4,5,4,3);
    print_r(array_flip(array_flip($ar)));Array ( [0] => 1 [1] => 2 [6] => 3 [5] => 4 [4] => 5 ) 
      

  3.   


    这样也是可以的。我只要保留一个不重复就行了。但是之前对应的input框的值会不会变成空值?
      

  4.   

    count查下个数是否一致就行
    $ar = array(1,2,3,4,5,4,3);
    $num1 = count($ar);
    $arr=array_flip(array_flip($ar));
    $num2 = count($arr);
    if($num1 != $mum2)
      {
      echo "重复";
      }