Page 1 of 1

newB- filling in the list menu with xml results

Posted: Wed Sep 06, 2006 7:01 am
by mlecho
i have the following xml parser that works fine for my xml file....

Code: Select all

<?php
$path="../html/";
$file="data.xml";
$absolute=$path.$file;
$data=file_get_contents($absolute);

$xmlData = new SimpleXMLElement($data);

//SimpleXMLElement Object ( [Row] => Array ( [0] => SimpleXMLElement Object ( [Cell] => SimpleXMLElement Object ( [Data] => Guest Employee ) )
//MUST remove ss: form xml file 
foreach($xmlData->Row as $leader){
	$eachLeader=$leader->Cell->Data;
	echo($eachLeader);
}

?>
i would like to fill the values/labels of a dropdown list menu with the results...At present, with my limited knowledge, i get all the values into the first element of the list menu....how can i make these results list appropriately?

my list box in html:

Code: Select all

<select name="leader" id="leader" tabindex="1">
    
              <option value="<?php include "getNames.php"; ?>"><?php include "getNames.php";?></option>
          
            </select></td>

Posted: Wed Sep 06, 2006 8:28 am
by mlecho
ok sorry all... a bike ride later:

Code: Select all

<select name="leader" id="leader" tabindex="1">
  <?php 
  include ("getNames.php");
  foreach($xmlData->Row as $leader){
  	$lname=$leader->Cell->Data;?>
	
	<option value="<?php echo ($lname);?>"><?php echo ($lname);?></option>
<?php }?></select>