Nodral Posted December 8, 2010 Share Posted December 8, 2010 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> Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted December 8, 2010 Share Posted December 8, 2010 we need to see getquiz.php Quote Link to comment Share on other sites More sharing options...
Nodral Posted December 8, 2010 Author Share Posted December 8, 2010 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> Quote Link to comment Share on other sites More sharing options...
Gem Posted December 8, 2010 Share Posted December 8, 2010 when you submit the form, whats in the address bar? Quote Link to comment Share on other sites More sharing options...
Zurev Posted December 8, 2010 Share Posted December 8, 2010 If your submit bar has ?test=blah then it should echo blah, however you are doing if (!$_GET) which to me I believe that means if the get is equal to 0 or false, you may want to use if (!isset($_Get['text'])) Quote Link to comment Share on other sites More sharing options...
Nodral Posted December 8, 2010 Author Share Posted December 8, 2010 I get /getquiz.php?test= Which says to me that no variable is being passed I know that $userrow['userid'] contains a value as I can echo this out when needed. Seems so simple, but got me stumped Quote Link to comment Share on other sites More sharing options...
Zurev Posted December 8, 2010 Share Posted December 8, 2010 Oh, I see it now.... You're doing <?php $userrow['userid']; ?> It needs to be <?php echo $userrow['userid']; ?> heh, let me know if it works, it should. Quote Link to comment Share on other sites More sharing options...
Nodral Posted December 8, 2010 Author Share Posted December 8, 2010 Cheers!!!! All sorted Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.