如何在选择内选择最大值

I have the following:

PHP CODE:

<select name="valoracion<?php echo $i; ?>" id="valoracion<?php echo $i; ?>">
    <?php
    for($h=1; $h<6; $h++){
        echo '<option value="'.$h.'">'.$h.'</option>';
    }
    ?>
</select>

This prints:

<select name="valoracion0" id="valoracion0">
    <option value="1">1</option>
    <option value="2">2</option>
    <option value="3">3</option>
    <option value="4">4</option>
    <option value="5">5</option>
</select>

When this <select> appears I want by default for the selected value to be the max number. How can I do this?

You can try this,

<select name="valoracion<?php echo $i; ?>" id="valoracion<?php echo $i; ?>">
    <?php
    for($h=1; $h<6; $h++){
       if($h == 5){
         echo '<option value="'.$h.'" selected >'.$h.'</option>'; 
       }else{
        echo '<option value="'.$h.'">'.$h.'</option>';
       }
    }
    ?>
</select>

This should work:

<select name="valoracion<?php echo $i; ?>" id="valoracion<?php echo $i; ?>">
    <?php
    for($h=1; $h<6; $h++){
        if($h == 5){ $selected = " selected=\"selected\""; }else{ $selected = NULL; }
        echo '<option value="'.$h.'"'.$selected.'>'.$h.'</option>';
    }
    ?>
</select>

Like this..

<select name="valoracion<?php echo $i; ?>" id="valoracion<?php echo $i; ?>">
    <?php
    $cnt=6;$sel=""; // <--- Add a variable $sel with nothing assigned
    for($h=1; $h<$cnt; $h++){
        if($h==($cnt-1)) //<-- Here goes the check
        {
            $sel="Selected";
        }
        echo '<option '.$sel.' value="'.$h.'">'.$h.'</option>';
    }
    ?>
</select>