I'm trying to retrieve data from an XML file using PHP and keep returning the same data in my xml file, regardless of what variable it is. I realise it should be in a loop.
I've been trying to get it to go into a loop but then the code doesn't seem to work. There doesn't seem to be any great examples on the web of combined if/else statements in a for loop. Anyone know of a quick work round? Thank you.
$xml=simplexml_load_file("images/database.xml") or die("Error: Cannot create object");
if ($word = 'Agitated') {
echo $xml->programme->mood['Agitated'] . "<br>";
echo $xml->programme->name . "<br>";
echo $xml->programme->description . "<br>";
}
else {
echo $xml->programme->mood['Calm'] . "<br>";
echo $xml->programme->name . "<br>";
echo $xml->programme->description . "<br>";
}