How to get values of multiselect box in PHP -


my multiselect box created this:

<?php     ini_set('display_errors',"1");      $select = '<select multiple>';      $lines = file('project-list.txt');     $fifth_column = array();     foreach ($lines $line){         $parts = preg_split('/\s+/', $line);         $count = 0;         foreach ($parts $partval){             if ((in_array($partval, $fifth_column) == false) && $count == 4){                 $fifth_column[] = $partval;             }             $count++;         }     }      foreach($fifth_column $value){           $select .= "<option value='".$value."'>".$value."</option>";     }      $select .= '</select>';      echo $select;      ?> <form action="" form method="post"> <input type="submit" class="ym-button ym-small" name = "apply" style="margin-top:1em;max-width:11em" value="apply" /> </form> 

i want able see user has selected in box when apply button clicked, want use information search project-list.txt value have selected, , display lines contain value. have been trying use isset($_get) select box doesn't have name.

added:

for example:

if list box contains: item1 item2 item3 item4

and user selects item1, want search in text file called project-list.txt item1 , print line. text file may like:

xxxx  hallone item 1 xxxx  halltwo item 2 xxxx  hallthree item 3 xxxx  hallfour item 1 

after have clicked apply button, after choosing item1 results should posted be:

xxxx  hallone item 1 xxxx  hallfour item 1 

try code

    <form action="" method="post">      <?php         ini_set('display_errors',"1");          $select = '<select multiple name = "project[]">'; // give name attribute select box          $lines = file('project-list.txt');         $fifth_column = array();         foreach ($lines $line){             $parts = preg_split('/\s+/', $line);             $count = 0;             foreach ($parts $partval){                 if ((in_array($partval, $fifth_column) == false) && $count == 4){                     $fifth_column[] = $partval;                 }                 $count++;             }         }          foreach($fifth_column $value){               $select .= "<option value='".$value."'>".$value."</option>";         }          $select .= '</select>';          echo $select;          ?>     <input type="submit" class="ym-button ym-small" name = "apply" style="margin-top:1em;max-width:11em" value="apply" />     </form> <?php if(isset($_post) && !empty($_post['project'])){     print_r($_post['project']); } ?> 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -