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

  • SEARCH
  • Home
  • 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 7509675
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T22:59:17+00:00 2026-05-29T22:59:17+00:00

Im pulling some data from an xml on a separate site and trying to

  • 0

Im pulling some data from an xml on a separate site and trying to display that data in a table, i can pull the data but when i tried to display the data in a table for each row i got the table headers, now i know why this is happening (because the table header echo is being called for every row) but i cant see how to fix it.

<?php
$url = "http://elcu.herobo.com/testarea/include/cd_catalog.xml";
$xml = simplexml_load_file($url);

foreach($xml->CD as $cd){
    echo "<table border='0' cellpadding='1' cellspacing='1' width'90%' id='1' class='tablesorter'><thead><tr> <th>Title</th> <th>Artist</th> <th>Company</th><th>Price</th></thead><tbody>";
    echo "<td width='25%'> ".$cd->TITLE."</td>";
    echo "<td width='25%'> ".$cd->ARTIST."</td>";
    echo "<td width='25%'> ".$cd->COMPANY."</td>";
    echo "<td width='25%'> ".$cd->PRICE."</td>";
    echo "</tbody></table>";
}
?>
  • 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-29T22:59:19+00:00Added an answer on May 29, 2026 at 10:59 pm

    You mean:

    <?php
    $url = "http://elcu.herobo.com/testarea/include/cd_catalog.xml";
    
    $xml = simplexml_load_file($url);
    
    echo "<table border='0' cellpadding='1' cellspacing='1' width'90%' id='1' class='tablesorter'>\n";
    echo "<thead><tr> <th>Title</th> <th>Artist</th> <th>Company</th><th>Price</th></thead>";
    echo "<tbody>";
    
    foreach($xml->CD as $cd){
        echo "<tr>";
        echo "<td width='25%'> ".$cd->TITLE."</td>";
        echo "<td width='25%'> ".$cd->ARTIST."</td>";
        echo "<td width='25%'> ".$cd->COMPANY."</td>";
        echo "<td width='25%'> ".$cd->PRICE."</td>";
        echo "</tr>";
    }
    echo "</tbody>";
    echo "</table>";
    
    ?>
    

    Note that you called table inside your foreach loop, and you also didn’t specify the start and end of the row with tr

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

Sidebar

Related Questions

I'm pulling some data from a table using LINQ 2 SQL...one of the pieces
I'm runing a query to pull some movie data from a source table to
I need some help pulling cell data from table when a user clicks the
I'm pulling some data from a forum and use it to display comments on
I am pulling some data from a mysql table via the following: $result =
I'm pulling data from an XML feed and manipulating it using the awesome SimpleXMLElement.
I'm having some little issues pulling data from Twitter. Basically I am building a
I'm unsingf RestKit in my iPad Project pulling some JSON Data from Server. The
We have an in-house application that pulls some data from some of Amazon's pages
I'm pulling in data from a flat file into a SQL Server 2008 table.

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.