Everybody! This is important. In a few days, these forums will be moving over to using the totally sweet Discourse platform. To ensure this migration happens smoothly with no loss of content, these forums are currently in a read-only mode. I do apologize for the inconvenience.

There is never a good time to turn the forums off for an extended period of time, but I promise the new forums will be a billion times better. I'm pretty sure of it.

See you all on the other side in a few days, and if you have any (non-technical) questions, please e-mail me at kirupa@kirupa.com. For technical questions, try to find a tutorial that corresponds to what you are looking for and post in the comments section of that page.

Cheers,
Kirupa

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