Create XML through php and mysql

Written by Sony on 8 October 2009 in , | 1 Comment

Here I am giving you the very basic sample code for creating the XML file through PHP and MYsql

<?php

// We'll be outputting a PDF
header('Content-type: text/xml');

echo "”

$db_name = “testDB”;
$connection = mysql_connect(“example.com”, “username”, “password”) or die(“Could not connect.”);
$table_name = ‘user’;

$query = “select * from ” . $table_name;

$result = mysql_query($query, $connection) or die(“Could not complete database query”);
$num = mysql_num_rows($result);

while ($row = mysql_fetch_assoc($result)) {
echo “”. $row['firstname'].”";
echo “”. $row['lastname'].”";
echo “

“. $row['address'].”

“;
echo “”. $row['age'].”";
}

?>

Tags: ,

One Response to “Create XML through php and mysql”

  1. ali says:

    thanks this is very usefull.

Leave a Reply

Wordpressapi is developer code book.
wordpressapi on Facebook
© 2010 Wordpressapi. All Rights Reserved. Reproduction without explicit permission is prohibited.