On Wed, Jun 22, 2011 at 18:43, Adam Preece <a...@blueyonder.co.uk> wrote:
> Hi Gang!
>
> i have 2 assoc arrays from 2 querys,
>
> first one is page categorys it consists of:
>        id
>        name
>
> second is pages
>        name
>        cat_id
>
> now, i am using smarty, so i pass arrays into the view. this i would like to 
> pass to the view and display within a html select element.
>
>        <select id="name">
>                <option value="CAT_ID">CAT NAME
>                        <option disabled="disabled">PAGE NAME ASSOCIATED TO 
> THE CAT NAME</option>
>                </option>
>        </select>
>
> and i cannot think of how i can structure an array to pass in to achieve this 
> and/or is it even possible :-/.
>
> i hope this makes sense.
>
> i'm truly stuck!

    If I'm understanding you correctly, this should get you started:

<?php

$arr = array(
  'inventory_100' => 'apples',
  'inventory_101' => 'oranges',
  'inventory_102' => 'pears',
  'inventory_103' => 'bananas',
);

echo '<select id="inventory_items">'.PHP_EOL;

foreach ($arr as $k => $v) {
  echo '  <option value="'.$k.'">'.$v.'</option>'.PHP_EOL;
}

echo '</select>'.PHP_EOL;
?>

    You can copy and paste that code (though I just typed it in here,
it should work) and it should illustrate the point.

-- 
</Daniel P. Brown>
Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting
(866-) 725-4321
http://www.parasane.net/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to