Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7190707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:34:23+00:00 2026-05-28T19:34:23+00:00

Rather noobish question but I have tried searching and just cannot find a solution.

  • 0

Rather noobish question but I have tried searching and just cannot find a solution. My problem is I have a table called Off, which stores all of the staffs holidays. However before a staff member may have that day off it has to be authorised. I have a query which gets all of the unauthorised holidays and I display them in a html table. The problem is that I need 2 radio buttons per record. one for authorise and one for deny. The radio buttons are displayed but when going through the records only one of the radio buttons is selectable. Is it possible to use radio buttons in this way?

<?php 
$path = $_SERVER['DOCUMENT_ROOT'];
$path .= "/Apollo/dbc.php";
include_once($path);



$rs_results = mysql_query("SELECT * FROM off WHERE IsItAuthorised='0' and isitsick='0' ORDER BY DayOff");

?>
<html>
<head>
<title>Administration Main Page</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<?php


    $limit = count($OffID);

if (isset($_POST['submit'])) {
    //Assign each array to a variable
    $id = $_POST['OffID'];
    $answer = $_POST['radio'];



    $limit = count($OffID);




$values = array(); // initialize an empty array to hold the values
    for($k=0;$k<$limit;$k++){
    $msg[] = "$limit New KPI's Added";


          $query = "UPDATE Off SET IsItAuthorised = '{$answer[$k]}' WHERE OffID = '{$OffID[$k]}'";
    }



    $Event = "INSERT INTO events (UserName, Event ) VALUES ('$_SESSION[user_name]', 'Entered New KPI' )";   



if (!mysql_query($query,$link)){
        die('Error: ' . mysql_error());
    } else {

        mysql_query($Event);
        echo "<div class=\"msg\">" . $msg[0] . "</div>";
    }




}                             
?>


</head>

<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="14%" valign="top"><?php

?>

    </td>
    <td width="74%" valign="top" style="padding: 10px;">

      <p><?php 
      if(!empty($msg)) {
      echo $msg[0];
      }
      ?></p>

      <p>
        <?php 
      $cond = '';






      $sql = "select * from off ";



      $rs_total = mysql_query($sql) or die(mysql_error());
      $total = mysql_num_rows($rs_total);


      ?>

      <p>

        <form name "searchform" action="/Apollo/Admin/HolidayRequests" method="post">
        <table width="100%" border="0" align="center" cellpadding="2" cellspacing="0">
          <tr class="mytables"> 
            <td width="4%"><font color="white"><strong>ID</font></strong></td>
            <td width="4%"> <font color="white"><strong>Staff Member</font></strong></td>
            <td width="10%"><font color="white"><strong>Day Off</font></strong></div></td>
             <td width="10%"><font color="white"><strong>Is It Authorized</font></strong></div></td>
            <td width="15%">&nbsp;</td>
          </tr>


          <tr> 
            <td>&nbsp;</td>
            <td width="10%">&nbsp;</td>
            <td width="17%"><div align="center"></div></td>
            <td>&nbsp;</td>
          </tr>
          <?php while ($rrows = mysql_fetch_array($rs_results)) {?>
          <tr> 
            <td><input type="" name="id[]" id="id[]" size="4" value="<?php echo $rrows['OffID'];?>" /></td>
            <td><?php echo $rrows['StaffMember']; ?></td>
            <td><?php echo date('d/m/Y', strtotime($rrows['DayOff']));?></div></td>

            <td> <span id="approve<?php echo $rrows['id']; ?>"> 
              <?php if(!$rrows['IsItAuthorised']) { echo "Pending"; } else {echo "Authorized"; }?>
              </span> </td>

              <td>


                    <input type="radio" name="radio[0]"  id="radio[0]" value="1" />Approve
                        <input type="radio" name="radio[1]"  id="radio[1]"  value="0" />Deny



         </td>
          </tr>

          <?php } ?>
        </table>
          <input name="submit" type="submit" id="submit" value="Submit">
      </form>


      &nbsp;</p>
      <?php


      ?>


      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p></td>
    <td width="12%">&nbsp;</td>
  </tr>
</table>
</body>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T19:34:25+00:00Added an answer on May 28, 2026 at 7:34 pm

    Your problem is to do with your use of the “name” attribute – this attribute is used in a special way on radio buttons.

    When you click on a radio button, all the other radio buttons with the same name are deselected – in your case, you will have half of the radio buttons on the page in one group and half in another, which would probably explain why you can only select one. I’d imagine you can actually select two at the same time, if you click on the right radio buttons.

    To fix this you’d need to have some kind of count for the while loop, ie:

    $resultNumber = 0;
    while ($rrows = mysql_fetch_array($rs_results)) {
    

    Then you’d need to use this number in the name (and also id) of the radio buttons –

    <input type="radio" name="radio<?php echo $resultNumber; ?>"  id="radio<?php echo $resultNumber; ?>" value="1" />
    

    Then simply increment the $resultNumber at the end of each iteration –

    <?php 
        $resultNumber++;
    } 
    ?>
    

    Alternatively, you could use the primary key of the row from the database table you’re querying to distinguish groups, but not knowing the table structure I couldn’t give sample code for that.

    Further reading on radio buttons (also a source for the name attribute problem) :
    http://www.echoecho.com/htmlforms10.htm

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This may be rather noobish but I'm gonna ask anyhow. I have a class
Rather silly question, but I can't seem to find the answer in the docs
I know this is a rather noobish question, but no amount of googling or
Rather a simple question. But the implications are vast. Over the last few weeks
Rather Trivial Question. So I tried to do this: if (array[0]==some_string) where array is
This is quite a noobish question, I have searched for a few hours now
Rather a simple question, this one - but I've no experience with VS macros,
Rather than just writing a new function called import() i'd like to know if
A rather basic question, I guess, but I want help with it. I need
I hate that I have to ask a homework question on here, but I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.