I’ll try and be brief but concise.
I have a PHP form page that populates a drop-down box with data (magazine names) from an array, and then, if posted, outputs it to another page.
However, I have a second array within the form (containing subscription links), that I also need to send to the output page, depending on what was chosen from the drop-down box. If that makes sense.
For example, if the value for for $arrayOne[7] is chosen from the drop-down box, I need to post_GET the value for $arrayTwo[7] over to the output page automatically, as well.
Can anyone help?
default.php:
$arrayOne[0] = "magazineA";
$arrayOne[1] = "magazineB";
etc...
$arrayTwo[0] = "subscriptionLinkA";
$arrayTwo[1] = "subscriptionLinkB";
etc...
<form action="index2.php" method="get">
<?php
echo '<select name="publication">';
foreach ($magazine as $publication)
{
echo '<option name="publication" value="' . $publication . '">' . $publication . '</option>';
}
echo '</select>';
?>
<input type="submit">
</form>
index2.php:
<p>
If you have subscribed to <?php echo $_GET["publication"]; ?>,
you will receive your hard-copy in due course. If you are not a current subscriber,
<a href="#">click here</a> to subscribe.
</p>
Since the value from
$array2is completely dependant on the value of$array1,$_GET['a1']can act as a lookup for the other value. ie you don’t have to pass$a2at all.On index2.php, you’d have something like this: