Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6967851
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:22:33+00:00 2026-05-27T16:22:33+00:00

I have a for loop displaying XML data from the last.fm API. Im wanting

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T16:22:34+00:00Added an answer on May 27, 2026 at 4:22 pm

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a while loop from a query called $result . Inside this while
I have a List of TableLayout's that are each generated from data in my
I have divs created within a while loop displaying a MySQL query. I'd like
I have an ul list with a query and a while loop displaying the
I have this query: $result = mysql_query(SELECT id,pic0,bio,url FROM .$table. WHERE id LIKE '%custom%'
I have a loop that reads each line in a file using getline() :
I have a loop created with each, check this example: $('.foo').each(function(i){ //do stuff });
I have the following inside a foreach loop (displaying my various videos), I'm trying
I have a while loop that is going through and displaying an RSS icon
I have two tables that I want to fetch data from. Lets call them

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.