用SQLYOG。里面有一个导入数据到XML

解决方案 »

  1.   

    <?php
    $hostname_conn = "localhost";
    $database_conn = "image_gallery";
    $username_conn = "root";
    $password_conn = "fuckme";
    $conn = mysql_pconnect($hostname_conn, $username_conn, $password_conn) or trigger_error(mysql_error(),E_USER_ERROR); 
    ?>
    <?php
    // Query the database and get all the records from the Images table 
    mysql_select_db($database_conn, $conn);
    mysql_query("SET NAMES 'GBK'");
    $query_rsImages = "SELECT ID, AlbumName, ImagePath, ImageDescription, UploadDate FROM images";
    $rsImages = mysql_query($query_rsImages, $conn) or die(mysql_error());
    $row_rsImages = mysql_fetch_assoc($rsImages);
    $totalRows_rsImages = mysql_num_rows($rsImages);// Send the headers
    header('Content-type: text/xml;charset=GBK');
    header('Pragma: public');        
    header('Cache-control: private');
    header('Expires: -1');
    ?>
    <?php 
    echo('<?xml version="1.0" encoding="GBK"?>'); 
    ?>
    <images>
      <?php if ($totalRows_rsImages > 0) { // Show if recordset not empty ?>
      <?php do { ?>
    <image>
    <ID><?php echo $row_rsImages['ID']; ?></ID>
    <album><![CDATA[<?php echo $row_rsImages['AlbumName']; ?>]]></album>
    <path><![CDATA[<?php echo $row_rsImages['ImagePath']; ?>]]></path>
    <description><![CDATA[<?php echo $row_rsImages['ImageDescription']; ?>]]></description>
    <date><![CDATA[<?php echo $row_rsImages['UploadDate']; ?>]]></date>
    </image>
        <?php } while ($row_rsImages = mysql_fetch_assoc($rsImages)); ?>
    <?php } // Show if recordset not empty ?>
    </images>
    <?php
    mysql_free_result($rsImages);
    ?>