trollolodn

#php: combobox for search-page using $_GET method

May 16th, 2013
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.63 KB | None | 0 0
  1. <?php
  2.     $rp_type = array(0=>'Vàng kiếm', 1=>'Vàng tiêu');
  3. ?>
  4. <select name="report_type" id="report_type">
  5.     <?php
  6.         $index_rp_type = intval(isset($_GET['report_type']) ? $_GET['report_type'] : -1);
  7.         if($index_rp_type >= 0 && $index_rp_type < count($rp_type)){
  8.             echo '<option value="'.$index_rp_type.'">'.$rp_type[$index_rp_type].'</option>';
  9.             unset($rp_type[$index_rp_type]);
  10.             foreach ($rp_type as $key => $value) {
  11.                 echo '<option value="'.$key.'">'.$value.'</option>';
  12.             }
  13.         } else{
  14.             foreach ($rp_type as $key => $value) {
  15.                 echo '<option value="'.$key.'">'.$value.'</option>';
  16.             }
  17.         }
  18.     ?>
  19. </select>
Advertisement
Add Comment
Please, Sign In to add comment