Results 1 to 5 of 5
-
05-06-2012, 03:14 AM #1WHT Addict
- Join Date
- Sep 2009
- Posts
- 167
how to fetch data from mysql to xml file using php
Hi there
i have 1 file ( index.php ) and one table in database
the table structure is : ( ID , Name , Phone )
i want to fetch this data to xml file look like that :
<ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://tempuri.org/">
<string>
1|Adam|100001
</string>
<string>
1|Calaman|100001
</string>
<string>
1|Serah|100001
</string>
</ArrayOfString>
i want to php code to select the data and the show it on xml file .
can you please tell me how can i do this ?
Thank you
-
05-07-2012, 05:51 PM #2WHT Addict
- Join Date
- Sep 2009
- Posts
- 167
i'am still need help .
-
05-08-2012, 01:07 PM #3Newbie
- Join Date
- May 2012
- Posts
- 11
Not pretty, but it's close:
mysql_connect($dbhost, $dbuser, $dbpass);
@mysql_select_db($dbschema);
$query = "select ID, NAME, PHONE, from table_name";
$result = mysql_query($query);
$i = 0;
print "<ArrayOfString">\n";
while ($i < mysql_numrows($result)) {
print "<string>\n";
print mysql_result($result,$i,"ID") . "|";
print mysql_result($result,$i,"ID") . "|";
print mysql_result($result,$i,"ID") . "\n";
print "</string>\n"
$i++;
}
print "</ArrayOfString>\n";
May the force be with you.
-
05-08-2012, 09:26 PM #4WHT Addict
- Join Date
- Sep 2009
- Posts
- 167
-
05-09-2012, 01:33 AM #5Newbie
- Join Date
- May 2012
- Posts
- 11
I guess I need to know more about how you're trying to do it.
Perhaps you need to change the headers to tell the client you're sending xml. Put this at the top of your php:
header ("Content-Type:text/xml");
Similar Threads
-
Extracting data from XML file by PHP
By tarsius in forum Programming DiscussionReplies: 4Last Post: 10-13-2011, 01:48 AM -
PHP, reading from an xml file
By Shib in forum Programming DiscussionReplies: 2Last Post: 06-21-2010, 03:03 PM -
PHP, Mysql Fetch Error Help
By pcnet21 in forum Programming DiscussionReplies: 5Last Post: 08-18-2006, 01:31 PM -
inserting data to mysql using php..from file?
By SFA-Dark in forum Programming DiscussionReplies: 3Last Post: 01-26-2005, 02:21 AM -
Fetch info off a website and put it into a database - PHP/MYSQL
By mrsam in forum Employment / Job OffersReplies: 4Last Post: 10-31-2004, 04:52 PM