PHP按钮无法正常显示

I have a for loop displaying XML data from the last.fm API. Im wanting to add a button to each individual result from the query, however It is simply appearing as a piece of text and not recognized as a button.

$xmlmusic = new SimpleXMLElement($result); 

$releases = $xmlmusic->xpath('artist/similar/artist'); 
foreach ($releases as $artist) { 
$artistResult .= '<div class="searchitem">';
$artistName = $artist->name . PHP_EOL;
$artistResult .= $artist->name . PHP_EOL;
$artistResult .= '<form name="favourite" action="'.$_SERVER['PHP_SELF'];'" ."   method="POST">';
$artistResult .= '<input type="submit" id="graphic" value="favourite">add</form>'; 
$artistResult .= '</div>';

<?php echo $artistResult ?>

This is displaying as a small box with "add" however it isn't being seen as a button.

Link to page: Artist Search

Any help is appreciated,

JB

The first issue is in this line:

$artistResult .= '<form name="favourite" action="'.$_SERVER['PHP_SELF'];'" ."   method="POST">';

You are mixing and matching quotes. Try:

$artistResult .= '<form name="favourite" action="' . $_SERVER['PHP_SELF'] . '"' . ' method="POST">';

Or better:

$artistResult .= sprintf('<form name="favourite" action="%s" method="POST">', $_SERVER['PHP_SELF']);

Or even better, just remove the action attribute as an empty action means by default to submit to the same URL.

Your second issue is that you are creating many submit buttons all with the same ID. HTML requires that ID attributes are unique-- you cannot use the same ID on multiple elements.