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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:50:55+00:00 2026-06-14T17:50:55+00:00

So basically, I have an array of Modules and I want to have a

  • 0

So basically, I have an array of Modules and I want to have a drop-down menue that users can then select what grade they got. This works fine, however, I would like the results to be stored inside of an array, to however many values they selected. So for example:

If someone selected “40” in Mod1 and in Mod2 they selected “20” then the array would be like this:

mod1=>40

mod2=>20

…

Here is the code so far, it’s probably something stupid, I just cannot get my head around it.

<?php

$modules = array('Mod1', 'Mod2', 'Mod3');   

if(!isset($_POST['submitted']))
{
    echo '<form method="post">';

    echo 'Please enter the grades you got for each Module: <br />';
    foreach($modules as $module)
    {
        echo $module . ': <input type="text" name="grades[]" value=""> <br />';
    }
    echo '<br /><input type="submit" name="submit" value="Go!">';
    echo '<input type="hidden" name="submitted" value="TRUE">';

}else{

    $input = $_POST['score[]'];
    foreach($modules as $i => $module){
        $input[$module] = $input[$i];
        var_dump($input[$module] = $i);
        //unset($input[$i]);
    }
    //var_dump($input);

}

?>
  • 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-14T17:50:56+00:00Added an answer on June 14, 2026 at 5:50 pm

    You could use a name that groups the values of the selects in POST into one array:

    echo '<select name="score[]">';
    

    You can then use:

    $input = $_POST['score[]'];
    foreach($modules as $i=>$module){
        $input[$module] = $input[$i];
        unset($input[$i]);
    }
    var_dump($input);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a large multidimensional array and I basically want to drop the first
I have a pretty simple problem. Basically I have an array called $list that
I am learning about arrays, and basically I have an array that collects a
So, basically I have an NSArray . I want to get an array with
I have two modules that should over ride other urls, basically /management/category/edit/id/1 (Edit Category
Basically I have and array of integers that vary in size. I need to
So basically I have a huge array of arrays (only a 2-d array)... My
Basically I have this string $str=word1 word2 word3; I need array( 'word1', 'word2', 'word3'
Basically, I have an array like this: val base_length = Array( 0, 1, 2,
Basically, I have an array of keywords, and a piece of text. I am

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.