newB- filling in the list menu with xml results

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mlecho
Forum Commoner
Posts: 53
Joined: Wed Feb 02, 2005 9:59 am

newB- filling in the list menu with xml results

Post 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>
mlecho
Forum Commoner
Posts: 53
Joined: Wed Feb 02, 2005 9:59 am

Post 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>
Post Reply