building html form select menus from arrays in php

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Craig White
Date:  
To: PLUG-discuss
Subject: building html form select menus from arrays in php
spent a lot of time today on this - researching and can't seem to make
it work.

<?php

function build_select_box ($picklist) {

  echo '<SELECT NAME="'."drop_list".'">';
  for ($x=0; $x<count($picklist); $x++) {
    echo '<OPTION VALUE="'.$picklist[$x].'"';
    echo '>'.'</OPTION>';
  }
  echo '</SELECT>';
}


$picklist = array("john", "paul", "george", "ringo");

echo '<html><body>';
echo '<form action="http://linuxserver/horde/horde-utils/test2.php"
method="post" target="db_get_attributes">';
build_select_box($picklist);
echo '<input type="submit" name="OK" value="OK">';
echo '</input></form></body></html>';
?>

It should be obvious what I am trying to get - is a pull down 'select'
menu with the 4 names listed and I am actually going to pass this a much
larger array when time comes.

I can't make this work...what's the secret?

Note that if you try to copy/paste - the line that starts
echo '<form action...

will wrap to the next line

Craig

---------------------------------------------------
PLUG-discuss mailing list -
To subscribe, unsubscribe, or to change you mail settings:
http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss