title: Unique radio name in php while loop
body: <p>Well, I've following Php code which generate a table with radio button so that user can select only one radio button in <strong>EVERY</strong> row. But to select only one radio button in <strong>Every</strong> row it's must be a unique name in <strong>EVERY</strong> row, Right ? But I can't get any idea how do i set a unique name in while loop. Can you guys give me any idea or solutions ?</p>
  
  <p><strong>Php code:</strong></p>
  
  <pre><code>$action = htmlspecialchars($_SERVER['PHP_SELF'])."?class=$class_from";  
  echo "&lt;form method='post' action='$action' name='attendence'/&gt;";
  echo "&lt;table width='100%' cellpadding='0' cellspacing='0' border='0'&gt;";
  echo "&lt;tr&gt;";
  echo "&lt;td class='tdhead' valign='top' width='200'&gt;&lt;b&gt;Student Name&lt;/b&gt;&lt;/td&gt;";    
  echo "&lt;td class='tdhead' valign='top' width='250'&gt;&lt;b&gt;Roll No&lt;/b&gt;
  &lt;/td&gt;";             
  echo "&lt;td class='tdhead' valign='top' width='250'&gt;&lt;b&gt;Class Name&lt;/b&gt;
  &lt;/td&gt;";             
  echo "&lt;td class='tdhead' valign='top' width='200'&gt;&lt;b&gt;Present / Not present&lt;/b&gt;
  &lt;/td&gt;";                 
  echo "&lt;td class='tdhead' valign='top' width='200'&gt;Check All &lt;input type= 'checkbox' 
  onclick='checkAll(this)' /&gt;&lt;/td&gt;";                  
  echo "&lt;/tr&gt;";
  
  
  while($res2 = mysql_fetch_array($sql2))
  {
  
  $sname = inputvalid($res2['sname']);
  $roll = inputvalid($res2['roll']);
  $class = inputvalid($res2['class']);
  
  echo "&lt;tr&gt;";                
  echo "&lt;td class='tdhead2' valign='top'&gt;$sname&lt;/td&gt;";
  echo "&lt;td class='tdhead2' valign='top'&gt;$roll&lt;/td&gt;";
  echo "&lt;td class='tdhead2' valign='top'&gt;$class&lt;/td&gt;";        
  echo "&lt;td class='tdhead2' valign='top'&gt;
  &lt;input type='radio' name='ch[]' value='1' /&gt;&amp;nbsp;&lt;input type='radio' name='ch[]' 
  value='1' /&gt;
  &lt;/td&gt;";                     
  echo "&lt;td class='tdhead2' valign='top'&gt;&amp;nbsp;&lt;/td&gt;";                
  echo "&lt;/tr&gt;";               
  
  }
  
  echo "&lt;tr&gt;";                
  echo "&lt;td class='tdhead2'&gt;&amp;nbsp;&lt;/td&gt;";
  echo "&lt;td class='tdhead2'&gt;&amp;nbsp;&lt;/td&gt;";
  echo "&lt;td class='tdhead2'&gt;&amp;nbsp;&lt;/td&gt;";             
  echo "&lt;td class='tdhead2'&gt;&amp;nbsp;&lt;/td&gt;";
  echo "&lt;td class='tdhead2'&gt;&lt;input type='submit' value='Record' name='Submit' 
  class='submit' /&gt;&lt;/td&gt;";                
  echo "&lt;/tr&gt;";               
  
  echo "&lt;/table&gt;";
  echo "&lt;/form&gt;";
  </code></pre>
  
  <p>Thanks for your help. </p>
  
  <p><strong>Update:</strong></p>
  
  <pre><code>echo "&lt;td class='tdhead2' valign='top'&gt;";
  echo '&lt;input type="radio" name="ch'.$counter++.'[]" value="1"&gt;';
  echo "&amp;nbsp;";
  echo '&lt;input type="radio" name="ch'.$counter.'[]" value="0"&gt;';
  echo "&lt;/td&gt;";                       
  </code></pre>