XML
|
|
|
|
<?php //Developed by -==[Mihir Shah]==- during my Project work
//for the output header("Content-type: text/xml");
//to create connection to database $connection = mysql_connect("127.0.0.1","username", "password")
or die ("could not connect to database");
//to select the database here test is the sample database come with mysql
$db = mysql_select_db("test",$connection)
or die ("Couldn't select database.");
$rs = mysql_query("select * from tablename",$connection)
or die ("invalid query");
//count the no. of columns in the table $fcount = mysql_num_fields($rs);
//you can choose any name for the starting tag echo ("<result>");
while($row = mysql_fetch_array( $rs ) )
{
echo ("<tablerow>");
for($i=0; $i< $fcount; $i++)
{ $tag = mysql_field_name( $rs, $i );
echo ("<$tag>". $row[$i]. "</$tag>");
}
echo ("</tablerow>");
}
echo ("</result>"); ?>
|
|
|
Usage Example
|
|
|
Rate This Script
|
|
|
|