Please somebody help me how to get the values of Radio Button arrays. here are my codes

<?php include("conn.php");
$query = "SELECT * FROM pointsprof, subject WHERE pointsprof.Total >= subject.IM108";

	 
$result = mysql_query($query) or die(mysql_error());

$row = mysql_fetch_array($result) or die(mysql_error());
do {echo '<form action="subjectload.php" method="POST" name="theForm" onsubmit="return validateFormOnSubmit(this)">
<form id="form1" name="form1" method="post" action="">
  <table width= "200">
    <tr>
      <td><label>
        <input type="radio" name="'.$row['name'].'" value="'.$row['name'].'" id= "RadioGroup1_0" />
         '.$row['name'].'</label></td><br/>
    </tr> 
  </table>';} while($row = mysql_fetch_array($result) ?><input type="submit" name="submitType" value="CONTINUE">

Recommended Answers

All 3 Replies

Do you really need the do-while iteration????
why not just code

1

While($row=mysql_fetch_array($result)){
    // BLA BLA BLA here.

Also your form tag<form action="subjectload.php" method="POST" name="theForm" onsubmit="return validateFormOnSubmit(this)"> not good.

The form opening and closing tags must always be outside the iteration and the body of the form inside unless you want to provide each button with its own executions.

Are you planning to have a multiple delete radio button or what?. That the user selects what to delete and just click on the send button to execute the action??.

Provide more info if you can. I need more insight if you really need my help.

Do you really need the do-while iteration????
why not just code

1
PHP Syntax (Toggle Plain Text)
While($row=mysql_fetch_array($result)){
// BLA BLA BLA here.

Also your form tag<form action="subjectload.php" method="POST" name="theForm" onsubmit="return validateFormOnSubmit(this)"> not good.

The form opening and closing tags must always be outside the iteration and the body of the form inside unless you want to provide each button with its own executions.

Are you planning to have a multiple delete radio button or what?. That the user selects what to delete and just click on the send button to execute the action??.

Provide more info if you can. I need more insight if you really need my help.

actually sir. I'm planning to have an update radio button. the user selects the value of the updates according to the query result, then if the user clicks the send button a field in the mysql database would be updated. that is how I planned it to be. I would really be grateful for your help sir.

Do you see that on line 8 and 9 you have 2 form tags . with a different actions.

psedo:

$query= "select * from foo"; table foo got id, name, 

$select=mysql_query($query) or die (mysql_error());// always do this

//Declare form tag here.

echo "<form action='#' name='form'>"; other form headers bla bla...
echo "<table style='width:60%;'>  "; // Table opening

// do the while loops here
while($row=mysql_fetch_array($select)){

  echo "<tr><td><input type='radio' name='radio[]' value=$row[name]> $row[name]</td><tr>";

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

Pay attention to the input name radio[]; you need to iterate through to get the id for the fields you will need to update.

Hope you get the idea.

Explore :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.