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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T09:05:13+00:00 2026-06-16T09:05:13+00:00

Can somebody tell me the PHP code and MySQL query so I can post

  • 0

Can somebody tell me the PHP code and MySQL query so I can post radio buttons data into MySQL fields? I’ve a MySQL table called “Attendance” which has four fields:

  • present
  • absent
  • leave
  • holiday

My HTML form contain four radio buttons as well like

<input type="radio" name="present" value="1" />
<input type="radio" name="absent" value="2" />
<input type="radio" name="leave" value="3" />
<input type="radio" name="holiday" value="4" />

What I want is that if someone select absent radio button, then 2 should go to absent field in Attendance Table and other 3 fields will be empty in table; if someone select present then 1 should go to present field in Attendance and other 3 fields of absent leave holiday will be empty.

Also names are differents of 4 radio buttons, so there is problem that i can select all 4 radio buttons. How can I make them select one out of 4? I know if names are same then I have choice to select 1 but here is different issue, 4 different fields.

  • 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-16T09:05:14+00:00Added an answer on June 16, 2026 at 9:05 am

    Give all elements of the radio group the same name. This will do it for the HTML part. In PHP you do a simple switch depending on the REQUEST value:

    <?php
        $defaultInsertData = array(0,0,0,0);
        $currentValue = intval($_REQUEST['FIELDNAME']);
        switch($currentValue) {
            case 1:
                $defaultInsertData[0] = 1;
                break;
            case 2:
                $defaultInsertData[1] = 2;
                break;
            case 3:
                $defaultInsertData[2] = 3;
                break;
            case 4:
                $defaultInsertData[3] = 4;
                break;
        }
        // and here you have your array with the four elements.... 
        var_dump($currentValue);
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can somebody tell me how to convert some English data into Marathi language dynamically
can somebody tell me why my code is not working? class Connection { public
TO_CHAR(( TO_DATE(calendar_key,'YYYYMMDD' )+ 1),'IW') week Can somebody tell me what's happening in this query?
We want to store product prices and weight (kg/pound) in MySQL. Can somebody tell
I am a beginner in PHP and XML. Can somebody tell me how to
Can somebody tell me how to treat .inc files as .php so I can
Can somebody tell me why code analysis shows issues from generated files? I do
can somebody tell me how can I check whether a table exists in microsoft
Can somebody tell me what's wrong with this code? 1046: Type was not found
Can somebody tell me how to get mod_rewrite to rename this: our-work-section.php?id=3&title=something to our-work-section/something/3

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.