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

  • SEARCH
  • Home
  • 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 9019985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:53:58+00:00 2026-06-16T04:53:58+00:00

This question is solved. Code is below. Currently I have a piece of code

  • 0

This question is solved. Code is below.

Currently I have a piece of code that is something like this:

while ($query…) {
<checkbox form named "rating"> <submit button for "rating">
} 

All that, x20. The x20 is determined by the variable $rpp (results per page. It’s not shown in the code, since it’s irrelevant to the question). Each form has their individual “submit” button.

What I want to achieve is, I want to give checkbox and radio button all individual names, so instead of what I have now, I can have the submit button outside the while-loop, meaning, there is only ONE submit button for all x20 checkbox/radio button forms.

E.G checkbox_0, checkbox_1,…

My only question is, how do I achieve this? And where do I play my submit button? Am I asking the right questions too? I apologize if I am sounding a bit vague. If you have a question, please ask, I will answer it.

I gave it a try in my code below. It seems it’s not a practice many people do, so most of my Googling did not turn up anything too useful, though I do have an idea of where to start. Could someone give me some guidance?

<?

if (isset($_POST['formSubmit'])){
  $j = 1;
  while ($j < $_GET['rpp']) {
    $rating = mysql_real_escape_string($_POST['rating'.$j]);
    $accountID = $_POST['accountID'.$j]; 

    mysql_query("UPDATE Spreadsheet SET rating='$rating' WHERE accountID='$accountID'");
    $j++;
  }
}

$k = 1; ?>

<form name ="rating" method ="POST" action ="" > <?
while($row = mysql_fetch_array($query)){  

    // Drop-down menu

    $values = array('0 - No rating','1 - Very Bad','2 - Bad','3 - Average','4 - Above Average');

    echo "<input type = \"hidden\" name = \"accountID" . $k . "\" value = \"" . $row['accountID'] . "\" >";
    for($i = 0; $i < count($values); $i++){ ?>
          <input type="radio" name="rating<? echo $k; ?>" value="<?php echo $values[$i]; ?>" id="rbl_0" <? if($row['rating'] == $i) echo "checked='checked'"; ?>/>
          <? echo $values[$i] ?> <br> <? 
        }

$k++;
} ?>

 <input type ="Submit" name ="formSubmit" value ="Submit and Next Page" />
 </form> <?

EDIT: The output of this code at the moment shows individual submit buttons for each form field. What I would like to achieve is to have one submit button for all the form-fields.

EDIT 2: Figured it out! Final edit is how I did it. For others who may stumble on this question in the future.

  • 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-06-16T04:53:59+00:00Added an answer on June 16, 2026 at 4:53 am

    Try this: you want to move your form declaration outside of your while loop. Which also means that you want to move your submit button outside your while loop. Everything inside can stay the same because your radio buttons have unique names per while loop iteration and are grouped per for loop iteration.

    <form name ="rating" method ="POST" action ="" > 
    <?php
    while($row = mysql_fetch_array($query)){ 
      $values = array('0 - No rating','1 - Very Bad','2 - Bad','3 - Average','4 - Above    Average'); ?>
      echo "<input type = \"hidden\" name = \"accountID" . $k . "\" value = \"" . $row['accountID'] . "\" >";
      for($i = 0; $i < count($values); $i++){ ?>
          <input type="radio" name="rating<? echo $k; ?>" value="<?php echo $values[$i]; ?>" id="rbl_0" <? if($row['rating'] == $i) echo "checked='checked'"; ?>/>
          <? echo $values[$i] ?> <br> <? 
        } ?>
     } ?>
     <input type ="Submit" name ="formSubmit" value ="Submit" />
    </form> 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

edit This question is solved! Having something weird. I'm using html { font-size: 100%
I have asked this question before and the problem was half solved in the
I understand the problem that OSGI solved thanks to this question.... What does OSGi
This is an Amazon interview Question.I have solved this problem in O(n) using dynamic
I will start by saying that this is a 2-part question. I have a
Note: This question was marked as solved once, but it figured out that upgrading
I'm trying to solve this problem, its not a homework question, its just code
This is not really a question because I just solved the problem, but I
My question is not about how to solve this error(I already solved it) but
This question is more a semantic-algorithmic-data-structure question than a F# syntactically question. I have

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.