Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Dynamic XML from PHP and MySQL

New Here ,
Mar 15, 2011 Mar 15, 2011

Copy link to clipboard

Copied

Hi,

I'm learning php and I'm trying to get to grips with dynamic xml and php  coming from a database.  The trouble I am having is I can't get my code  to give any output.  I don't get an error I message, I just can't get  the xml to display.  If anyone can give me any pointers as to what I'm  doing wrong that would be great...

Here's the code I have.


<?php  

DEFINE
('DB_USER', 'root');

DEFINE ('DB_PASSWORD', 'password');

DEFINE ('DB_HOST', 'localhost');

DEFINE ('DB_NAME', 'flashphpbible'); 



$link = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);



$query = "SELECT * FROM dynamicxml WHERE id=1";

$result = mysqli_query($link, $query); 

$xmlData .= " ";

$xmlData .= "<store>\n";  



while(
$row = mysqli_fetch_array($result));

{    

$xmlData .= " <item>\n";    

$xmlData .= "     <name>".$row['name']."</name>\n";     $xmlData .= "     <section>".$row['section']."</section>\n";     $xmlData .= "     <price>".$row['price']."</price>\n";

$xmlData .= "     <inStock>".$row['instock']."</inStock>\n";     $xmlData .= " </item>\n"





$xmlData .= "</store>\n";  echo "response=".$xmlData; ?>

Thanks for any help offered.
Ben.

TOPICS
Server side applications

Views

649
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Mar 16, 2011 Mar 16, 2011

Copy link to clipboard

Copied

LATEST

Can´t help with your specific issue, but in my opinion the PHP version of the "Query to XML" sample code posted on Adobe Labs is much easier to follow respectively adapt for PHP debutants, and it will also add something important which your code doesn´t: a correct XML header.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines