Jump to content

Why is my $_GET not returning a value?


Nodral

Recommended Posts

Hi All

 

Please take a look at the code below.  I am sucessfully accessing a database and pulling the details through into a HTML form with a drop down.  However I then want to use a variable (test) in another page.  However I cannot get the variable userrow['userid'] to send a value to my getquiz.php.  What am I doing wrong?

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
  <TITLE> New Document </TITLE>
  <META NAME="Generator" CONTENT="EditPlus">
  <META NAME="Author" CONTENT="">
  <META NAME="Keywords" CONTENT="">
  <META NAME="Description" CONTENT="">
</HEAD>
<?php
include_once "db.inc.php";
?>
<body>
<form action="getquiz.php" method="GET">
  <tr><td class="title">Please Select User</td> 
<td><select name="test">
<?php
$courseid = mysqli_query($link, 'SELECT id FROM mdl_quiz WHERE course = "225"; ');
if (!courseid)
{
$error = ' Error fetching course id: ' . mysqli_error($link);
include 'error.html.php';
exit();
}
else {
while($row = mysqli_fetch_array($courseid))
  {
  $user = mysqli_query($link, 'SELECT userid FROM mdl_quiz_attempts WHERE quiz =' . $row['id']);
  while ($userrow = mysqli_fetch_array($user))
  {
  $names = mysqli_query($link, 'SELECT firstname,lastname FROM mdl_user WHERE id=' . $userrow['userid']);
  while ($usernames = mysqli_fetch_array($names))
	  {?>
  <option value="<?php $userrow['userid']?>"> <?php echo $usernames ['firstname'] . " " . $usernames['lastname'] . $userrow['userid']; ?> </option>
  <?php
  		  }
  }
  }
}
?>
</select>
</td></tr>
<center><input type="submit" value="Submit"></center>
</table>
</form>
</body>
</html>

Link to comment
Share on other sites

I've kept it simple, I was just trying to echo it out to ensure it was working.

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
  <TITLE> New Document </TITLE>
  <META NAME="Generator" CONTENT="EditPlus">
  <META NAME="Author" CONTENT="">
  <META NAME="Keywords" CONTENT="">
  <META NAME="Description" CONTENT="">
</HEAD>

<BODY>
  <?php
  if (!$_GET['test'])
  {
  echo "fail";
  }

  echo $_GET['test'];
  //echo $userphpid;
  echo "hello";
  ?>
</BODY>
</HTML>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.