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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:06:06+00:00 2026-06-11T23:06:06+00:00

I am trying to pick out the correct question number from a table and

  • 0

I am trying to pick out the correct question number from a table and inserting it in the database. Lets say I have a table where it appends rows and that I have 3 rows, the table below will look something like this:

Question No     Image

1              (file input)
2              (file input)
3              (file input)

Below is the code that creates the table above:
var qnum = 1;

var $qid = $("<td class='qid'></td>" ).text(qnum);
var $image = $("<td class='image'></td>"); 

    var $fileImage = $("<form action='imageupload.php' method='post' enctype='multipart/form-data' target='upload_target' onsubmit='return imageClickHandler(this);' class='imageuploadform' >" + 
        "Image File: <input name='fileImage' type='file' class='fileImage' /></label><br/><br/><label class='imagelbl'>" + 
    "<input type='submit' name='submitImageBtn' class='sbtnimage' value='Upload' /></label>" + 
    "<label><input type='button' name='imageClear' class='imageClear' value='Clear File'/></label>" +
    "</p></form>"); 

$tr.append($qid);
$tr.append($image);


    ++qnum;
    $(".questionNum").text(qnum);
    $(".num_questions").val(qnum);

What my question is that lets say I use the file input in row 2 for example, how can I insert the question number within the same row as that file input to be inserted into the database (the question number inserted would obviously be 2)?

Another example is that if I use the file input in row 3 for example, how can I insert the question number within the same row as that file input to be inserted into the database (the question number inserted would obviously be 3)?

Below is the code I currecntly have on inserting the data into the database (main code):

$lastID = $mysqli->insert_id;         

 $imagequestionsql = "INSERT INTO Image_Question (ImageId, SessionId, QuestionId)  
    VALUES (?, ?, ?)"; 

     if (!$insertimagequestion = $mysqli->prepare($imagequestionsql)) { 
      // Handle errors with prepare operation here 
       echo "Prepare statement err imagequestion"; 
    } 

$qnum = 1;

$insertimagequestion->bind_param("isi",$lastID, $sessid, $qnum); 

$sessid =  $_SESSION['id'] . ($_SESSION['initial_count'] > 1 ? $_SESSION['sessionCount'] : ''); 

    $insertimagequestion->execute(); 

                if ($insertimagequestion->errno) { 
          // Handle query error here 
        } 

        $insertimagequestion->close(); 

At the moment the code above is just inserting number 1 each time for question number in the database

  • 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-11T23:06:07+00:00Added an answer on June 11, 2026 at 11:06 pm

    If I understood your question correctly, here’s the nice way to do it: PHP supports “subarrays” in $_POST, $_GET and $_FILES. I.E. if you have

    <input type="file" name="upload[1]" />
    <input type="file" name="upload[2]" />
    <input type="file" name="upload[3]" />
    

    You could easiy check which file upload was triggered with $_FILES[“upload”][X], where X is between 1 and 3. Same goes for $_GET and $_POST. Remember this trick because it’s very useful, especially if appending elements on the fly with JavaScript. E.g. you could have a code like:

    last_index = 1;
    //later in the code
    //....
    $('#container').append('<input type="file" name="upload['+last_index+']" />');
    last_index++;
    

    Then, in the PHP code you could check the length of the $_FILES[“upload”] array, and even get its keys with array_keys and check which file input has been “uploaded”. Hope this helps.

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

Sidebar

Related Questions

I'm trying to pick out unique elements from a collection of objects and then
For example, I'm trying to pick out the value Application Library from the following
I have a string that I'd like to pick out sub-strings from that start
I'm trying to have my TeamCity server pick up packages from NuGet, so I
We are crawling and downloading lots of companies' PDFs and trying to pick out
I'm trying to have the user pick an audio file and store the path
I am trying to pick out the optimal set of colors for a new
I am trying to implement some code to pick out the last line of
I'm trying to pick measurements out of a string in my treetop grammar. I'm
I am trying to use the select clause to pick out an object which

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.