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 8989403
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:15:01+00:00 2026-06-15T22:15:01+00:00

I have selected data from mysql and inserted them into a radio button form

  • 0

I have selected data from mysql and inserted them into a radio button form which is looped as shown:

if($num_rows) {

    echo '<form name="fixtureform" method="POST" action="index.php">';

    while ($row = mysql_fetch_assoc($result)) {

    echo $row["home_team"] . " vs " . $row["away_team"]. '<br />' . " Home" . '<input type="radio" name="win'.$row["home_id"].'" value="'.$row["home_id"].'"/>' ." Draw" . '<input type="radio" name="'.$row["home_id"].$row["away_id"].'" value="draw"/>' ." Away" . '<input type="radio" name="win'.$row["away_id"].'" value="' . $row["away_id"] . '"/>' .'<br />';

}
    echo '<input type="Submit" Name="Submitacc" Value="Submit your teams">';
    echo '</form>';

} else { 
        echo "There are no fixtures today ";
        }

I then have an if statement for submitted values:

if($_POST['Submitacc']=='Submit your teams') {


    }

How would I say if the selected name of the radio button is win.$row[home_id] – insert value into mysql table. I’m struggling with the fact I can’t get $row[home_id] outside of the loop?

thanks in advance

  • 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-15T22:15:03+00:00Added an answer on June 15, 2026 at 10:15 pm

    Try as below

    $i=0;
    while ($row = mysql_fetch_assoc($result)) {
        echo $row["home_team"] . " vs " . $row["away_team"]. '<br />' . " Home" . '<input type="radio" name="result['.$i.']" value="h_'.$row["home_id"].'"/>' ." Draw" . '<input type="radio" name="result['.$i.']" value="draw"/>' ." Away" . '<input type="radio" name="result['.$i.']" value="a_' . $row["away_id"] . '"/>' .'<br />';
      $i++;
    }
    

    In Your PHP

    foreach($_POST['result'] as $value){
       if($value == 'draw') {
         //do stuff
       }
       else {
         $apart = explode('_',$value);
         if($apart[0]=='h'){
            //home team win
            echo $apart[1];
         }
         else {
            //away team win
            echo $apart[1];          
         }
       } 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm exporting some data from MySQL which can be selected through checkboxes on a
I have code which selects data from my database and then sets these selected
I have a table which show data from mysql database in HTML table like
I have a form which has a Combo Box Control. I have selected the
I have a PHP server script that SELECTs some data from a MySQL database.
I have to insert some data into a MySQL table. The data will be
I have a form-1 which has 4 fields. when the user inputs data in
I have a little script here which uses DOMDocument to get my data from
I use a form where i have listed the data from database like title,
I am dynamically loading data from mysql server into a list whose itemTpl is

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.