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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T21:37:53+00:00 2026-05-18T21:37:53+00:00

I have a form that submits parameters using standard HTML controls to a PHP

  • 0

I have a form that submits parameters using standard HTML controls to a PHP file. The PHP file then iterates through a csv file and returns the resuts via AJAX. If I select a dropdown menu from the form I get the data back no problem but when I then make another selection it doesn’t remember what I have previously selected so only the new parameter gets submitted. How do I ensure the previous selected control(s) get submitted? Any ideas or suggestions greatly appreciated.

search.php:

<?php
error_reporting(E_ALL & ~E_NOTICE);
require_once('includes/MagicParser.php');
$key = $_GET['key'];
$search = $_GET['search'];
$counter = 0;
function recordHandler($record)
{
global $key;
global $search;
global $counter;

if ($record[$key] == $search) {
    if ($counter % 2) {
        print "<tr class=\"alt_row\">";
    } else {
        print "<tr>";
    }       
    print "<td>".$record['Subject']."</td>";
    print "<td>".$record['Tutor']."</td>";      
    print "<td>".$record['Level']."</td>";
    print "<td>".$record['Course Type']."</td>";
    print "<td>".$record['Course Code']."</td>";
    print "<td>".$record['Primary Center']."</td>";
    print "<td>".$record['Lesson 1 Date']."</td>";
    print "<td><a href=\"#\"></a></td>";
    print "<td><a href=\"#\"></a></td></td>";
    print "</tr>";
} else {
    return;
}
$counter ++;
}

print "
<table id=\"results\">
<tr>
       <th>Subject</th>
        <th>Tutor</th>
        <th>Level</th>
        <th>Type</th>
        <th>Code</th>
        <th>Center</th>
        <th>Date</th>
        <th>Timetable</th>
        <th>Outline</th>
</tr>
";

MagicParser_parse("includes/course-data.csv", "recordHandler");

print "
</table>
<div id=\"pager_display\"></div>
";
?>

scripts.js:

function showCourse(search, key)
{
if (search == "") {
    document.getElementById("dynamic_display").innerHTML = "";
    return;
}

if (window.XMLHttpRequest) {
    xmlhttp = new XMLHttpRequest();
} else {
    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}

xmlhttp.onreadystatechange = function()
{
    if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
        document.getElementById("dynamic_display").innerHTML = xmlhttp.responseText;
        pager = new Pager('results', 15);
        pager.init(); 
        pager.showPageNav('pager', 'pager_display'); 
        pager.showPage(1);
    }
}

xmlhttp.open("GET", "search.php?key="+ key +"&search=" + search, true);
xmlhttp.send();
}

/*
function disableEnableForm(form, boolean)
{
var formElements = form.elements;

for (i = 0; i < form.length; i ++) {
    formElements[i].disabled = boolean;
}
}
*/
  • 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-18T21:37:54+00:00Added an answer on May 18, 2026 at 9:37 pm

    I would store them in $_SESSION. However, even once you get that squared away your basic search logic doesnt allow for multiple parameters so youll need to reconfigure that as well.. It might look something like the following:

    if(isset($_SESSION['search']))
    {
       $search = $_SESSION['search'];
    }
    else
    {
      $search = array();
    }
    
    $key = $_GET['key'];
    $search[$key] = $_GET['search'];
    
    // store updated search in array
    $_SESSION['search'] = $search;
    
    $counter = 0;
    function recordHandler($record)
    {
      global $key;
      global $search;
      global $counter;
    
    
    
      foreach($search as $key => $value)
      {
        if($record[$key] != $value)
        {
          // if the record doesnt have all values that match for $key then its not a match
          return;
        }
      }
    
        if ($counter % 2) {
            print "<tr class=\"alt_row\">";
        } else {
            print "<tr>";
        }       
        print "<td>".$record['Subject']."</td>";
        print "<td>".$record['Tutor']."</td>";      
        print "<td>".$record['Level']."</td>";
        print "<td>".$record['Course Type']."</td>";
        print "<td>".$record['Course Code']."</td>";
        print "<td>".$record['Primary Center']."</td>";
        print "<td>".$record['Lesson 1 Date']."</td>";
        print "<td><a href=\"#\"></a></td>";
        print "<td><a href=\"#\"></a></td></td>";
        print "</tr>";
    
       $counter ++;
    }
    

    This isnt by any means complete Im not sure exactly how your parser works and all that fun stuff – and this only supports an AND search – it will only return rows which match all supplied key-value pairs in the search. You would also need to implement something to clear the search parameters so the user can start over too. But you should be bale to get the basic idea…

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

Sidebar

Related Questions

I have a button that I would like to disable when the form submits
I have a form on an HTML page with multiple submit buttons that perform
I have form that displays several keywords (standard set of choice lists that changes
I have a form that excepts a file upload in ASP.NET. I need to
I have a form that uses jQuery to submit an ajax post and it
I have a form that contains a GridView control which is databound to an
I have a form that I would like to style. specifcally I would like
I have a form that searches all rows in a single table (TServices) that
I have a form that is sending in sizes of things, and I need
I have a form that has multiple fields, and for testing purposes is there

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.