I want to make a dropdown list with the values from inside the xml file. The dropdown is present but it is blank on the web. Why? Is there something i've missed?
I have the following code:
<form method="post" action="">
<?php
echo "<select>";
$xml = simplexml_load_file('curs.xml');
foreach ($xml->item as $item)
{
echo "<option value='".$item->name."'></option>";
}
echo "</select>";
?>
</form>
The code for the xml file:
<prod>
<item>
<name>Cheese</name>
<price>4.25</price>
</item>
<item>
<name>Milk</name>
<price>8.12</price>
</item>
<item>
<name>Egg</name>
<price>0.81</price>
</item>
</prod>
/home/sites/www/resources/curs.xml(or whatever it is). EDIT: I've just noticed you're not printing the values within the<option>tags either, so they'll appear blank. See: codepad.org/XArgKuSq