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
https://forums.phpfreaks.com/topic/221020-why-is-my-_get-not-returning-a-value/
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>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.