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
https://forums.phpfreaks.com/topic/227360-geting-two-variables/
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;

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.

 

 

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

 

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.