Form Select

General discussions related to php

Moderators: macek, egami, gesf

New php-forum User
New php-forum User
Posts: 18
Joined: Mon Jan 23, 2012 7:40 pm

Form Select

Postby bobbygerez » Mon Sep 17, 2012 5:36 pm

Code: Select all

   <head><title>File Input Output</title></head>
      if (!isset($_POST['submit'])){
      $files = file("file.txt");
<form action="file_array.php" method="post">
   <select name="name[]">
         foreach ($files as $file ){
            $file = explode(",", $file);
            list($name, $address, $age) = $file;
       <option value="<?php echo $name; ?>"><?php echo $name; ?></option>
       <option value="<?php echo $address; ?>"><?php echo $address; ?></option>
      <input type="submit" name="submit" value="send" />
      } else {
      echo $a[0];

The code works fine but I want to have another <option value="<?php echo $address; ?>"><?php echo $address; ?></option>. The problem is if I add this code it will only add to the <option value="<?php echo $name; ?>"><?php echo $name; ?></option>. I need to separate them. Any idea is highly appreciated. Thanks.

User avatar
New php-forum User
New php-forum User
Posts: 25
Joined: Fri Sep 14, 2012 12:06 am

Re: Form Select

Postby TomCornar » Tue Sep 18, 2012 3:50 am


do u mean to display the two dropdowns.One for name and another for address..

Tom Cornar
Trinay Technology Solutions

Return to “PHP General”

Who is online

Users browsing this forum: No registered users and 2 guests