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

The Archive Base Latest Questions

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

Sorry for my English ! I have a poll system with one question and

  • 0

Sorry for my English !
I have a poll system with one question and 4 answers :

Answer_id   Question_id   answers     vote
   10           1           ball        1
   11           1           radio       3
   12           1           tv          5
   13           1           car         8

I have 4 input text to input the answers for users using the poll to vote:

<input type="text" name="ans1" id="ans1"/>
<input type="text" name="ans2" id="ans2"/>
<input type="text" name="ans3" id="ans3"/>
<input type="text" name="ans4" id="ans4"/>

When I want to Update the answers, How can I query ?
Thanks for answer my questiong 😀

  • 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-13T09:39:44+00:00Added an answer on June 13, 2026 at 9:39 am

    You should have all the inputs along with a submit button inside the form tag. Also inside the form tag, have a hidden input which will contain the id of the question as value. When you click submit, it will post the all the inputs including the hidden input. In the processing page (form action page), get the value of the hidden input(you will need this in the where clause of your query). Then write an update query in the below way.

    You definately dont want to update all the 4 answers but only one answer as every question will have only one answer.
    Assuming your table name is questions:

    $ans1 = $_POST['ans1'];
    $ans2 = $_POST['ans2'];
    $ans3 = $_POST['ans3'];
    $ans4 = $_POST['ans4'];
    
    if(!empty($ans1))$answer = $ans1;
    else if(!empty($ans2))$answer = $ans2;
    else if(!empty($ans3))$answer = $ans3;
    else if(!empty($ans4))$answer = $ans4;
    $id = $_POST['id']; //This is coming from the hidden input box
    $updateSQL = mysql_query("UPDATE questions SET answers = '$answer' WHERE Question_id= '$id');
    

    Also it will be good if you can put a check if the user is not inputting all 4 answers through javascript.
    Are you sure you need an update query and not an insert query ?
    This can also be done through jquery (ajaxed way), but you didnt mention how you want to do it.

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

Sidebar

Related Questions

sorry about input mistakes, english its not my mother lang. I have this code
First, sorry for my English. I have a question when inflating layout: I have
Sorry for english this might be very basic Question, I have an Application where
at first, sorry about my english. My question is: I have php generated dynamic
Hi everyone, sorry my English is not good. I have the next question: what
Sorry for my English. I have a a small question: There is a variable
Sorry ,my English is poor, I have never speak English after I leave the
Sorry for bad english and bad title! I have the table post id title
Sorry for my bad English. Just like what I asked. I have this class
First, sorry for my bad english, I'm French. Here the problem : 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.