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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:11:26+00:00 2026-06-12T08:11:26+00:00

I have two forms with a GET method. when I submit the 1st form

  • 0

I have two forms with a GET method. when I submit the 1st form I get this URL

http://127.0.0.1/astronomy/student_enrollment.php?class_name_data=1&classNameGetDetails=

and when I submit the 2nd form that also had a GET method. my URL changed to this

http://127.0.0.1/astronomy/student_enrollment.php?class_name_for_enrollment=Planet&sy_for_enrollment=2012-2013&sy_for_enrollment=45&number_of_student_enrolled=&time_schedule_student=Monday+to+Friday+8%3A00-9%3A00&generateFields=Generate

the first query string was removed and replaced by the 2nd query string

I want my URL to look like this

http://127.0.0.1/astronomy/student_enrollment.php?class_name_data=1&classNameGetDetails=&class_name_for_enrollment=Planet&sy_for_enrollment=2012-2013&sy_for_enrollment=45&number_of_student_enrolled=&time_schedule_student=Monday+to+Friday+8%3A00-9%3A00&generateFields=Generate

The two query strings will combine with a separator of & and not ?. how will I do this?

this is my code

<div class="enrollmentContent">
    <div class="classNameChoices">
    <label>Choose Class Name</label>
    <form action="" method="get">

        <select name="class_name_data">
            <?php
            $table = "classes";
            $data = array(
            'teacher_id' => $session_id
            );
            $class_name_query = show_filtered_rows($table, $data);
            while($rows = mysql_fetch_array($class_name_query)){
                $id = $rows['id'];
                $class_name = $rows['class_name'];
            ?>
            <option value="<?php echo $id; ?>"><?php echo $class_name; ?></option>
            <?php
            }
            ?>
        </select>
        <input type="submit" name="classNameGetDetails" value="" />
    </form>
    </div>
    <?php
        if(isset($_GET['classNameGetDetails'])){
            $data2 = array(
            'id' => $_GET['class_name_data'],
            'teacher_id' => $session_id
            );
            $class_name_data_query = show_filtered_rows($table, $data2);
            $rows_class = mysql_fetch_array($class_name_data_query);
    ?>
    <div class="classDetailsByClassName">
    <form action="" method="get">
        <input type="hidden" value="<?php echo $rows_class['class_name']; ?>" name="class_name_for_enrollment" />
        <input type="hidden" value="<?php echo $rows_class['school_year_from']."-".$rows_class['school_year_to']; ?>" name="sy_for_enrollment" />
        <input type="hidden" value="<?php echo $rows_class['enrollees']; ?>" name="sy_for_enrollment" />
        <label>Class Name <span><?php echo $rows_class['class_name']; ?></span></label>
        <label>SY <span><?php echo $rows_class['school_year_from']."-".$rows_class['school_year_to']; ?></span></label>
        <label>Maximum No. of Enrollees <span><?php echo $rows_class['enrollees']; ?></span></label>
        <div class="registerDetails">
            <div>
                <label>Number of students to enroll</label>
                <div><input type="number" name="number_of_student_enrolled" value=""/></div>
            </div>
            <div>
                <label>Schedule</label>
                <div>
                    <select name='time_schedule_student'>
                        <option value="Monday to Friday 8:00-9:00">Monday to Friday 8:00-9:00</option>
                        <option value="Monday to Friday 10:00-11:00">Monday to Friday 10:00-11:00</option>
                        <option value="Monday to Friday 1:00-2:00">Monday to Friday 1:00-2:00</option>
                        <option value="Monday to Friday 2:00-3:00">Monday to Friday 2:00-3:00</option>
                        <option value="Monday to Friday 9:00-10:00">Monday to Friday 9:00-10:00</option>
                        <option value="Monday to Friday 3:00-4:00">Monday to Friday 3:00-4:00</option>
                    </select>
                </div>
            </div>
            <div><input type="submit" name="generateFields" value="Generate" /></div>
        </div>
    </form>
    </div>
    <div class="enrollmentFields">
        <?php
        if(isset($_GET['generateFields'])){
            echo $_GET['class_name_for_enrollment'];
        }
        ?>

    </div>
    <?php
    }
    ?>
</div>

and my function

function show_filtered_rows($table, $data){
    foreach($data as $fields=>$field_data){
        $show_data[] = "`".$fields."` = '".$field_data."'";
    }
    return mysql_query("SELECT * FROM `$table` WHERE ".implode(" AND ",$show_data));
}
  • 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-12T08:11:27+00:00Added an answer on June 12, 2026 at 8:11 am

    Just add the values of your first form into your second form as hidden values.

    <input type="hidden" name="class_name_data" value="<?php echo $_GET['class_name_data']; ?>" />
    <input type="hidden" name="classNameGetDetails" value="<?php echo $_GET['classNameGetDetails']; ?>" />
    

    Here is the full code with the 2 above lines added. The PHP function doesn’t change.

    <div class="enrollmentContent">
        <div class="classNameChoices">
        <label>Choose Class Name</label>
        <form action="" method="get">
    
            <select name="class_name_data">
                <?php
                $table = "classes";
                $data = array(
                'teacher_id' => $session_id
                );
                $class_name_query = show_filtered_rows($table, $data);
                while($rows = mysql_fetch_array($class_name_query)){
                    $id = $rows['id'];
                    $class_name = $rows['class_name'];
                ?>
                <option value="<?php echo $id; ?>"><?php echo $class_name; ?></option>
                <?php
                }
                ?>
            </select>
            <input type="submit" name="classNameGetDetails" value="" />
        </form>
        </div>
        <?php
            if(isset($_GET['classNameGetDetails'])){
                $data2 = array(
                'id' => $_GET['class_name_data'],
                'teacher_id' => $session_id
                );
                $class_name_data_query = show_filtered_rows($table, $data2);
                $rows_class = mysql_fetch_array($class_name_data_query);
        ?>
        <div class="classDetailsByClassName">
        <form action="" method="get">
            <input type="hidden" name="class_name_data" value="<?php echo $_GET['class_name_data']; ?>" />
            <input type="hidden" name="classNameGetDetails" value="<?php echo $_GET['classNameGetDetails']; ?>" />
            <input type="hidden" value="<?php echo $rows_class['class_name']; ?>" name="class_name_for_enrollment" />
            <input type="hidden" value="<?php echo $rows_class['school_year_from']."-".$rows_class['school_year_to']; ?>" name="sy_for_enrollment" />
            <input type="hidden" value="<?php echo $rows_class['enrollees']; ?>" name="sy_for_enrollment" />
            <label>Class Name <span><?php echo $rows_class['class_name']; ?></span></label>
            <label>SY <span><?php echo $rows_class['school_year_from']."-".$rows_class['school_year_to']; ?></span></label>
            <label>Maximum No. of Enrollees <span><?php echo $rows_class['enrollees']; ?></span></label>
            <div class="registerDetails">
                <div>
                    <label>Number of students to enroll</label>
                    <div><input type="number" name="number_of_student_enrolled" value=""/></div>
                </div>
                <div>
                    <label>Schedule</label>
                    <div>
                        <select name='time_schedule_student'>
                            <option value="Monday to Friday 8:00-9:00">Monday to Friday 8:00-9:00</option>
                            <option value="Monday to Friday 10:00-11:00">Monday to Friday 10:00-11:00</option>
                            <option value="Monday to Friday 1:00-2:00">Monday to Friday 1:00-2:00</option>
                            <option value="Monday to Friday 2:00-3:00">Monday to Friday 2:00-3:00</option>
                            <option value="Monday to Friday 9:00-10:00">Monday to Friday 9:00-10:00</option>
                            <option value="Monday to Friday 3:00-4:00">Monday to Friday 3:00-4:00</option>
                        </select>
                    </div>
                </div>
                <div><input type="submit" name="generateFields" value="Generate" /></div>
            </div>
        </form>
        </div>
        <div class="enrollmentFields">
            <?php
            if(isset($_GET['generateFields'])){
                echo $_GET['class_name_for_enrollment'];
            }
            ?>
    
        </div>
        <?php
        }
        ?>
    </div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two separate forms on the index.php page: <form action=search_results.php method=get id=search_housing_area> <input
In this JSfiddle have I two forms. This is duplicated twice <form action= method=post>
I have two forms. The first form is the mainForm, this never goes anywhere.
I have a form using GET method. This form might have large amount of
I have Two forms in my index.php and am trying to get them to
I have two forms and form1 needs to get data from form2 , i
I have two forms, and so two different submit buttons, for one page (page
I have two forms on my website, and I use jQuery to submit them,
I'm trying to get my head around this one: Say you have two models
I have a a form in Django with two inline forms. One of them

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.