0

Am trying to send 2 variables from one page to another but in url i can see only one variable when i use &, but if i use ',' both variables are appear in thew url but in 2nd page if i tried to get the variables using $_GET[testid] both variables display,how to access 2 variables differently in 2nd page?

echo "<tr><td align=center ><a href=quiz.php?testid=$x[0]&subid=$x[3]><font size=4>$x[2]</font></a>";

in second page i use this code

$a=$_GET['subid'];
$b=$_GET['testid'];
echo $a;
echo $b;

the url in the next page

http://localhost/online/quiz.php?testid=187

4
  • Can you copy here the URL? Maybe something is missing from your x array. Commented Apr 25, 2016 at 15:13
  • Use curly braces: ?testid={$x[0]}& etc... Commented Apr 25, 2016 at 15:25
  • If you are looking to keep what you have, PHP has complex curly syntax where you can do double quotes so: "testid={$x[0]}" in combination with escaped quotes: "<a href=\"quiz.php?testid={$x[0]}\">" Commented Apr 25, 2016 at 15:25
  • @AbraCadaver we were thinking along the same lines... Commented Apr 25, 2016 at 15:26

2 Answers 2

1

It all gets a bit complicated when you have to use both single and double quotes

This should produce what you want

echo '<tr><td align="center"><a href="quiz.php?testid=' . $x[0] . '&subid=' . $x[3] . '"><font size="4">' . $x[2] . '</font></a>';
Sign up to request clarification or add additional context in comments.

Comments

0
echo "<tr><td align=center >
<a href='quiz.php?testid=".$x[0]."&subid=".$x[3]."'>
  <font size=4>$x[2]</font>
</a>";

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.