PhpRiot
Recent Code Pastes

Listing 1541

Submitted by Glass, 31 August 2008
 
    
    $id=$_GET['id'];
    
    //Load XML file
    if (file_exists('album.xml')) 
    {
        $xml = simplexml_load_file('album.xml');
    }
    else 
    {
        exit('Failed to open XML file.');
    }
 
    //Fix so the images loop
    $max = count($xml->picture);
    if($id>$max-1)
    {
        $id=0;
    }
    else if($id<0)
    {
        $id=$max-1;
    }
    
    $id=1;
 
    //Print picture and text
    echo('<div id="pictop"></div><div id="picmain"><br /><img src="');
    echo($xml->picture[$id]->location);
    echo('" id="picture" alt="');
    echo($id);
    echo('" /><br /><span id="caption">');
    echo($xml->picture[$id]->text);
    echo('</span></div><div id="picbottom"></div>');
Submit a Follow Up