The forums have permanently moved to forum.kirupa.com. This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.

Results 1 to 5 of 5

Thread: mysql to xml output

  1. #1

    mysql to xml output

    I've followed the tutorial on the site but i can't get it to format the data the way i need it here is the php code.
    PHP Code:
     <?php

    include_once"conn.php";

    $query "SELECT * FROM points ORDER BY id DESC";
    $resultID mysql_query($query) or die("Data not found.");

    $xml_output "<?xml version=\"1.0\"?>\n";

    for(
    $x $x mysql_num_rows($resultID) ; $x++){
        
    $row mysql_fetch_assoc($resultID);
        
    $xml_output .= "\t'<marker>\n";
        
    $xml_output .= "lat=" .'"'$row['lat'] .'"';
        
    $xml_output .= "lng=" .'"'$row['lng'] .'"';
        
    $xml_output .= "title=" .'"'$row['title'] .'"';
        
    $xml_output .= "note=" .'"'$row['note'] .'"';
    }

    $xml_output .= "</marker>";

    echo 
    $xml_output;

    ?>
    and it outputs like this
    ' lat="41.8905"lng="12.4925"title="Colosseo"note="bl og"

    I need it to output like this
    <marker lat="41.8905" lng="12.4925" title="Colosseo" note="blog" icon=""/>

  2. #2
    PHP Code:
     <?php

    include_once"conn.php";

    $query "SELECT * FROM points ORDER BY id DESC";
    $resultID mysql_query($query) or die("Data not found.");

    $xml_output "<?xml version=\"1.0\"?>\n";

    for(
    $x $x mysql_num_rows($resultID) ; $x++){
        
    $row mysql_fetch_assoc($resultID);
        
    $xml_output .= "\t'<marker ";
        
    $xml_output .= 'lat="' $row['lat'];
        
    $xml_output .= '" lng="' $row['lng'];
        
    $xml_output .= '" title="' $row['title'];
        
    $xml_output .= '" note="' $row['note'] . "\"></marker>\n";
    }

    echo 
    $xml_output;

    ?>
    ?

  3. #3
    i think i figured out one of my biggest problems, my conn.php file had an html header

    still when i generate the data it doesn't display on the page only in the page source
    Last edited by tge1986; January 3rd, 2008 at 03:25 PM.

  4. #4
    Link me to the page or post the source code produced?
    Web Design and Web Development blog
    Designer Notice: Browser List for design compatibility

  5. #5

    It Works!

    I got it to work, It was mostly the issue with the conn.php file having an html header and then it was just figuring out where the tags ended and how to format them properly. thank you everyone for your help.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012