kreut Posted February 11, 2011 Share Posted February 11, 2011 Hello, I'm try (for the first time!) to pass two variables between two pages, namely, $_GET['assignment_id'] (generated from the last page) and $row['question_id']. From what I understand, I need a "&" to join the two variables. Unfortunately, my code isn't working: might there be some sort of concatenation or extra quotes that I need to get things rolling? Thank you for your help. <a href="../main_scripts/db_insert_assignment_question.php?question_id= <?php echo $row['question_id']&assignment_id=$_GET['assignment_id']; ?> ">Add Question</a> Quote Link to comment https://forums.phpfreaks.com/topic/227360-geting-two-variables/ Share on other sites More sharing options...
Nodral Posted February 11, 2011 Share Posted February 11, 2011 Hi You simply need a full stop <?php $assignment_id=$_GET['assignment_id']; echo $row['question_id'] . $assignment_id; ?> If you want a space between them when they echo out just use the following echo $row['question_id'] . " " . $assignment_id; Quote Link to comment https://forums.phpfreaks.com/topic/227360-geting-two-variables/#findComment-1172706 Share on other sites More sharing options...
kreut Posted February 11, 2011 Author Share Posted February 11, 2011 Thanks for pointing me in the right direction! My url now looks like: db_insert_assignment_question.php?question_id=35assignment_id=29 How then can I access these variables? (Right now I think that my php thinks that question_id has the value "35assignment_id=29") In other words, how can I now use: question_id=35 and assignment_id = 29. Quote Link to comment https://forums.phpfreaks.com/topic/227360-geting-two-variables/#findComment-1172715 Share on other sites More sharing options...
PFMaBiSmAd Posted February 11, 2011 Share Posted February 11, 2011 Your link is currently missing the & that separates the different parameters. I recommend just forming and outputting the entire link at once - echo "<a href='../main_scripts/db_insert_assignment_question.php?question_id={$row['question_id']}&assignment_id={$_GET['assignment_id']}'>Add Question</a>"; Quote Link to comment https://forums.phpfreaks.com/topic/227360-geting-two-variables/#findComment-1172724 Share on other sites More sharing options...
kreut Posted February 11, 2011 Author Share Posted February 11, 2011 Perfect! Thanks so much.... Quote Link to comment https://forums.phpfreaks.com/topic/227360-geting-two-variables/#findComment-1172743 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.