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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:20:11+00:00 2026-05-26T06:20:11+00:00

So currently I am using a 3rd party software application to get results from

  • 0

So currently I am using a 3rd party software application to get results from various surveys. This application is sending the results to a page via a $_POST variable.

So for example..

$demoEMP = $_POST['demoEMP'];

This just stores the answer from the specific question into a variable.

What I want to do is store Questions 1-20 in POST variables and Insert them into a database..
What I don’t want to do is write 20+ Insert commands or 20+ $var = $_POST[‘var’]

So I was thinking a for loop would do the trick… This is what I have so far… based on looking at various methods and tutorials. =/

for ($i = 0; $i < 55; $i++) {
$answer = "Q{$i}";
echo $_POST[$answer];
}

Am I even on the right track? Thanks for your help!

UPDATE::
Kas’ solution worked great.

I used something like this…

foreach ($_POST as $i => $v)
{
if (preg_match("/^Q\d+$/",$i)) {

// Here we insert value $v to database
$query_2 = mysql_query("INSERT INTO SGresult VALUES ('', '', '$pID', '$SGQID','$v')") or die('Error: '.mysql_error ());

}
}

However, I am now trying to figure a way to add an ID to the question and have that ID auto increment… on every insert. I thought I could do something like $SGQID++ but that does not seem to be working.. anyone have any thoughts?

Thanks again!

okay after some more tinkering it seems the placement of the ++ was off and it needed to be after the query… the correct code is as follows.

$SGQID= 1;

foreach ($_POST as $i => $v)
{

if (preg_match("/^Q\d+$/",$i)) {

// Here we insert value $v to database
$query_2 = mysql_query("INSERT INTO SGresult VALUES ('', '', '$pID', '$SGQID','$v')") or die('Error: '.mysql_error ());
$SGQID++; //added value to increment Question ID in DB

}
}
  • 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-26T06:20:12+00:00Added an answer on May 26, 2026 at 6:20 am
    foreach ($_POST as $i => $v) {
      if (preg_match("/^Q\d+$/",$i)) {
        // Here we insert value $v to database
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're currently using a 3rd party API that provides datetime in the following format:
In my current project I am using a 3rd party library which has no
Currently using Google Analytics as a supplement to our paid tracking software, but neither
I'm using a 3rd party tool, which uses a 4th party plugin. Occasionally, the
I'm using a 3rd party service to process images and they provide a handy
I'm currently writing a PHP script that 3rd party clients will be able to
I started using git to track my customizations to a 3rd party web app.
Currently we use log4net of version 1.2.10.0 and we should start using some 3rd
We're using a 3rd party XML messaging service that requires an embedded PDF file
I work at a company who does 3rd party iOS development for various enterprises.

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.