Using two variables in a link to open another page

Hi There,

I am trying to get a link using two variables to go to a specific webpage with results.

[php]$iPartID = $_GET[“PartID”];
$iColor_ID = $GET[“ColorID”][/php]

I have set the two get statements up above

and in the table I have the following link

[php]ECHO “

<a href=“Part_Color.php?PartID=”.$row[‘PartID’].’” style=“text-decoration:none;”>’.$row[‘PartID’]."
";[/php]

I want to add in

[php][‘colorid’][/php]

into the link so it takes me to another page where I just get the partID and ColorID displaying, I know that to get the later I need to create a where statement with a & to separate the two variable but I am stuck for what to do on a link. I have looked it up and cannot seem to find any solid answers.

Thanks

Simply use & for your next variable.

[php]echo “

<a href=“Part_Color.php?PartID=”.$row[‘PartID’].’&Color_ID=” . $row[‘ColorID’] . “” style=“text-decoration:none;”>’.$row[‘PartID’]."
";
[/php]

thanks for your reply, I get an error of a white screen when I try the code you provided. The error seems to be in the

[php]Color_ID=" . $row[‘ColorID’] . “” style=“text-decoration:none;”>’.$row[‘PartID’]."
";[/php][/php]

[php]echo “

<a href=“Part_Color.php?PartID=”.$row[‘PartID’].’&Color_ID=” . $row[‘ColorID’] . “” style=“text-decoration:none;”>’.$row[‘PartID’]."
";[/php]

when I put it into the Notepad ++ the .$row[‘ColorID’] is shaded a different color so my thought is that there is something wrong with the code before it, but I cannot for the life of me figure it out.

If you get a white screen you need to turn on error reporting in your development environment. You can do this easily by starting your script(s) with this:

[php]<?php

ini_set(‘display_errors’, 1);
ini_set(‘display_startup_errors’, 1);
error_reporting(E_ALL);[/php]

[hr]

Also this is a great example of how it would be simpler if you actually had proper markup in your editor. I strongly suggest separating PHP and HTML, like this

[php]<?php
// logic here
// then stop php before outputting HTML
?>

<?= $row['PartID'] ?>
[/php]

Thanks for your help!

Sponsor our Newsletter | Privacy Policy | Terms of Service