Board index   FAQ   Search  
Register  Login
Board index PHP PHP General

Form Select

General discussions related to php

Moderators: macek, egami, gesf

Form Select

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

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


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.
bobbygerez
New php-forum User
New php-forum User
 
Posts: 18
Joined: Mon Jan 23, 2012 7:40 pm

Re: Form Select

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

Hi,

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

Regards,
Tom Cornar
Trinay Technology Solutions
http://www.trinay.com
User avatar
TomCornar
New php-forum User
New php-forum User
 
Posts: 25
Joined: Fri Sep 14, 2012 12:06 am


Return to PHP General

Who is online

Users browsing this forum: No registered users and 3 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.