flemingmike Posted June 14, 2010 Share Posted June 14, 2010 im starting to hate php!?! i can only get this to display the first record from the xml. any ideas? <?php $xml = "http://www.durhamit.ca:8181/1.0/?method=database.search&searcharg=a"; $xml_content = file_get_contents($xml); transform_xml_to_html($xml); function transform_xml_to_html($xml) { $data = simplexml_load_file($xml); foreach($data as $tracks) { echo '<div class="weatherIcon">'; echo 'Artist: '.$tracks->track->artist.''; echo '</div>'; } } ?> Link to comment https://forums.phpfreaks.com/topic/204760-only-displaying-first-record/ Share on other sites More sharing options...
kenrbnsn Posted June 14, 2010 Share Posted June 14, 2010 Use this foreach: <?php foreach($data->tracks->track as $tracks) { ?> and change the "echo" to <?php echo 'Artist: '.$tracks->artist.''; ?> Ken Ken Link to comment https://forums.phpfreaks.com/topic/204760-only-displaying-first-record/#findComment-1072011 Share on other sites More sharing options...
flemingmike Posted June 14, 2010 Author Share Posted June 14, 2010 wicked. thanks. im still in awe that the little things make such a big difference. Link to comment https://forums.phpfreaks.com/topic/204760-only-displaying-first-record/#findComment-1072015 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.