Jump to content

Dropdown Concatenation?


eekscarykat

Recommended Posts

I am currently learning Zend/PHP on the fly. I've gone from 0 to 40 in about 2 months, as far as savviness is concerned. I am working on a form that I want to display array information of two things (shortname and fullname) in a drop-down list. I am thinking I need to do some sort of concatenation to achieve this, or would I do an array within an array? The array is defined in a value object and that draws the id, shortname and fullname. Shortname is the defined label in that file. In the form page, i have the LO ['full_name'] => LO ['label']... this inputs the right information into the database, but shows the full name. I want the drop-down to show it as following: Shortname|Fullname. This will be used in a couple of places once I get on the right track on how to accomplish this. I would be accepting of any help, as well as any resourced that could answer my question and help me finish this form.

:confused:

 

Cheers,

ESK

Link to comment
https://forums.phpfreaks.com/topic/262924-dropdown-concatenation/
Share on other sites

Not sure if this is even close to what you're looking for.

<?php
$names=array(
"id" => array(22,47,35),
"label" => array("Sally","Jim","John"),
"full_name" => array("Sally Field","Jim Beam","John Doe")
);
echo '<select name="names">';
foreach($names['id'] as $key => $id){
echo "<option value=\"$id\">{$names['label'][$key]}|{$names['full_name'][$key]}</option>";
}
echo '</select>';
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.