Jump to content

[SOLVED] Value in a dropdown


Mr Chris

Recommended Posts

Hi All,

 

I have a piece of code where I get the player_id value from the url at the top of the page.

 

Rather than this I want to get the value from variable named $player_one.

 


<?php $p_id = (isset($_GET['player_id']) ? intval($_GET['player_id']) : ''); ?> 
<select class="input" name="player_one" size="1"  style="width: 145" tabindex="1"> 
  <option value="" <?php echo ($p_id == '' ? 'selected="selected"' : ''); ?>>player_one</option> 
    <?php 
            $type_array=get_player_names(); 
            foreach ($type_array as $players) 
           { 
             ...code
          } 
     ?> 
</select>

 

 

So I thought it would be something like this:

 

<?php $p_id = $player_one ? $player_one : ''; ?>

 

Rather than:

 

<?php $p_id = (isset($_GET['player_id']) ? intval($_GET['player_id']) : ''); ?> 

 

But it does not pull out the value.  Can anyone help?

 

Thanks

 

Chris

 

Link to comment
https://forums.phpfreaks.com/topic/56338-solved-value-in-a-dropdown/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.