Jump to content

Geting two variables


kreut

Recommended Posts

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? :shrug:

 

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>

Link to comment
Share on other sites

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;

Link to comment
Share on other sites

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.

 

 

Link to comment
Share on other sites

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>";

 

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.