View Single Post
Old 10-27-2004, 02:35 PM   #2 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,444
sde is on a distinguished road
your example is confusing, when you are displaying multiple radio boxes, they should all be NAMED the same, but have different values. i.e.:
HTML Code:
<form method=post action=index.php>
Please select a rating:
<br>
  1 <input type=radio name=rating value=1>
  2 <input type=radio name=rating value=2>
  3 <input type=radio name=rating value=3>
<br>
<input type=submit>
</form>
now, i may be misunderstanding you, but if you did want to offer a rating for every componenet based on a component id, i'd do something like this:
PHP Code:
<form method=post action=index.php>
<?
$result 
mysql_query("select * from components order by headertxt");


while(
$row mysql_fetch_array($result)){
  echo 
$row['headertxt']."<br>";
  echo 
"1 <input type=radio name=c[".$row['cID']."] value=1>
  2 <input type=radio name=c["
.$row['cID']."] value=2>
  3 <input type=radio name=c["
.$row['cID']."] value=3>
  4 <input type=radio name=c["
.$row['cID']."] value=4>
  5 <input type=radio name=c["
.$row['cID']."] value=5><br><br>\n";
}

echo 
"<input type=submit name=submit value=submit></form>";

// if submit, print ( or write to db the values )
if($submit){
  if(
is_array($c)){
    foreach(
$c as $key => $value){
      echo 
"cID=".$key." / value=".$value."<br>\n";
    }
  }
}
hmm .. yeah, i think that is what you're trying to do.
__________________
Mike
sde is offline   Reply With Quote