Select tag returning two values

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
devesa
Forum Newbie
Posts: 10
Joined: Fri Sep 11, 2009 2:49 am

Select tag returning two values

Post by devesa »

Hello,

I have a table (REPORT) whose primary key is a set of two values (Id_game + Id_player).
In a form I would like to have a SELECT tag where I could chose a row representing both values, and send both of them through the form.
Something like this:

<select name="report">
<option value="WHAT I WRITE HERE?"> <?php echo $game1; ?> - <?php echo $player1; ?></option>
<option value="WHAT I WRITE HERE?"> <?php echo $game1; ?> - <?php echo $player2; ?></option>
<option value="WHAT I WRITE HERE?"> <?php echo $game2; ?> - <?php echo $player1; ?></option>
<option value="WHAT I WRITE HERE?"> <?php echo $game1; ?> - <?php echo $player2; ?></option>
</select>

THANKS
User avatar
DigitalMind
Forum Contributor
Posts: 152
Joined: Mon Sep 27, 2010 2:27 am
Location: Ukraine, Kharkov

Re: Select tag returning two values

Post by DigitalMind »

Maybe something like <option value="<?php echo $game1 . ',' . $player1 ?>"> ?
devesa
Forum Newbie
Posts: 10
Joined: Fri Sep 11, 2009 2:49 am

Re: Select tag returning two values

Post by devesa »

Yeah, I think this way will work. THANK YOU!
Ketrel
Forum Newbie
Posts: 6
Joined: Tue Sep 28, 2010 4:13 am

Re: Select tag returning two values

Post by Ketrel »

Perhaps value1,value2

and then explode it in php for your use?
User avatar
DigitalMind
Forum Contributor
Posts: 152
Joined: Mon Sep 27, 2010 2:27 am
Location: Ukraine, Kharkov

Re: Select tag returning two values

Post by DigitalMind »

$game_player_values = explode(',', $_REQUEST['report']);
Ketrel
Forum Newbie
Posts: 6
Joined: Tue Sep 28, 2010 4:13 am

Re: Select tag returning two values

Post by Ketrel »

DigitalMind wrote:$game_player_values = explode(',', $_REQUEST['report']);
Yeah, that's what I was saying :)
devesa
Forum Newbie
Posts: 10
Joined: Fri Sep 11, 2009 2:49 am

Re: Select tag returning two values

Post by devesa »

Thank you all!!
Post Reply