Q:

I need some assistance with PHP and updating the URL after a "?"

Hi so I have a project for class that is a mix of PHP, HTML, and javascript/Ajax.
One of the requirements is "Execute program.php on server passing it the N/V pairs following the "?" symbol." How do I do this?
First off.. I don't know what NV pairs are and the reading links we were given say nothing about them.. I Googled "Php nv pairs" and literally nothing relative comes up.
I did an in-class activity that upon clicking a button, the url would update and add stuff after the "?" but of course that same code isn't doing it anymore. My professor is terrible at explaining anything and leaves us to follow his typo instructions that aren't even complete.. 
Here's the code we were given with his comments trying to explain what to do:
// startgame function
// sart button pressed  check fields, if OK send to PHP via get request
function startgame(){
//Create the XMLHttpRequest Object

  var xmlhttp;
  // error handling
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
  try {
    xmlhttp = new XMLHttpRequest();
  } catch (e) {
  xmlhttp = false;
}
}
http = xmlhttp;

// The PHP server script, called with N/V pair with GET request
// Using get request the NV pairs follow "?" 
// execute program.php on server passing it the n/v pairs
// that follow the "?"
var url = "program.php?player1name="; 
// for this example, only pass to PHP games played
// "&" separates n/v pairs
// player1name is name of algorithm player 1 is using
player1name = document.JForm.p1name.value;
player2name = document.JForm.p2name.value;
gamesplayed = document.JForm.gamesplayed.value;
sdata = url+player1name+"&gamesplayed="+gamesplayed;
// for a "real" solution, pass more data to PHP about state of game
// send get request to server with n/v pairs of screen data
http.open("GET",sdata, true);  

// register with server what function to return data
http.onreadystatechange = handleHttpResponse;
// send request to server
http.send(null);

}

Anything will help, thanks!

A:

NV apis means "Name/Value pairs". Basically, in the terms you will be using them in, it is a key connected to its value with an equal sign. For example: username=johnconde. username is the key and johnconde is the value. An example more closely related to your code would be gamesplayed=20. gamesplayed is the key and 20 is the value.
Name/value pairs are commonly found in query strings and it looks like that's what you need to do with your code. You need to build a query string comprised of name/value pairs containing the values you need for your PHP script to do whatever it is it needs to do. It looks like the code already does this and you just need to build the form necessary for this JavaScript to work.

