Acquiring multiple values from one select option value. PHP HTML

How do I have acquire multiple values from one select option value. An example here,

<html>

<form method="post" action="#">
   <select name="retrive_destination">
       <?php while($row = mysql_fetch_assoc($result)){
                    $destinationID = $row['destinationID'];
                    $destination_place = $row['destination_place'];
                    echo '<option value="'.$destinationID.'">'.$destination_place.'</option>
       ?>
      <input type="submit">
</select>

</form>
</html>

How do i get both values '$destinationID' and '$destination_place' from one option value , when the form i submitted as i need both values when the user selects an option on the next step. THank you guys cheers.

Answers


Compose the two values and then explode them server-side

<html>

<form method="post" action="#">
   <select name="retrive_destination">
       <?php while($row = mysql_fetch_assoc($result)){
                    $destinationID = $row['destinationID'];
                    $destination_place = $row['destination_place'];
                    echo '<option value="'.$destinationID."_".htmlentities($destination_place).'">'.$destination_place.'</option>
       ?>
      <input type="submit">
</select>

</form>
</html>

Php server-side

$value= $_REQUEST['retrive_destination'];
$explode=explode("_",$value,2);
$destinationID =$explode[0];
$destination_place =$explode[1];

Need Your Help

How do Repositories fit with CQRS?

domain-driven-design cqrs ddd-repositories

According to Fowler (here), a repository "mediates between the domain and data mapping layers, acting like an in-memory domain object collection." So, for example, in my Courier Service application,

Speeding up Travis-CI dependencies installation for AngularJs project

node.js angularjs continuous-integration travis-ci

I've just started playing with Travis-CI and I managed to run my simple unit tests in a free version.