Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jan 2004
    Posts
    42
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Creating XML From MySQL

    I am trying to generate an XML feed from a MySQL database. It isn't working as I am sure I haven't made my script right. I would appreciate any help... here is my current script:

    PHP Code:
    <? include("config.php"); ?>
    <? header
    ("Content-Type: text/xml"); ?>

    <?
    $result 
    mysql_query("select * from products ORDER by name ASC LIMIT 10") or die (mysql_error()); 
    while (
    $row mysql_fetch_array($result))
    {

    echo 
    "<products>
    <link>$row[link]</link>
    <name>$row[name]</name>
    <description>$row[description]</description>
    </products>"
    ;

    }
    mysql_free_result($result);
    ?>

  • #2
    Regular Coder dniwebdesign's Avatar
    Join Date
    Dec 2003
    Location
    Carrot River, Saskatchewan
    Posts
    841
    Thanks
    15
    Thanked 9 Times in 9 Posts
    Don't know if this will help but here we go anyway:
    PHP Code:
    <? include("config.php"); ?> 
    <? header("Content-Type: text/xml"); ?> 
      
    <? 
    $result 
    mysql_query("SELECT * FROM products ORDER BY name ASC LIMIT 10") or die (mysql_error());  
    while (
    $row mysql_fetch_array($result)) 

      echo 
    "<products> 
      <link>"
    .$row[link]."</link> 
      <name>"
    .$row[name]."</name> 
      <description>"
    .$row[description]."</description> 
      </products>"



    mysql_free_result($result); 
    ?>
    Dawson Irvine
    CEO - DNI Web Design
    http://www.dniwebdesign.com


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •