hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Programming Discussion : how to fetch data from mysql to xml file using php
Reply

Programming Discussion Discussions related to web programming languages and other related issues. Topics may include configuration, optimization, practical usage and database connectivity.
Forum Jump

how to fetch data from mysql to xml file using php

Reply Post New Thread In Programming Discussion Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 05-06-2012, 03:14 AM
scal scal is offline
WHT Addict
 
Join Date: Sep 2009
Posts: 121

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
Attached Thumbnails
Click image for larger version

Name:	Untitled.png
Views:	42
Size:	2.7 KB
ID:	22338  

Reply With Quote


Sponsored Links
  #2  
Old 05-07-2012, 05:51 PM
scal scal is offline
WHT Addict
 
Join Date: Sep 2009
Posts: 121
i'am still need help .

Reply With Quote
  #3  
Old 05-08-2012, 01:07 PM
nickelsack nickelsack is offline
Newbie
 
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.

Reply With Quote
Sponsored Links
  #4  
Old 05-08-2012, 09:26 PM
scal scal is offline
WHT Addict
 
Join Date: Sep 2009
Posts: 121
Quote:
Originally Posted by nickelsack View Post
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.

thank you man for your help ,

but i think this will not export it xml file

Reply With Quote
  #5  
Old 05-09-2012, 01:33 AM
nickelsack nickelsack is offline
Newbie
 
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");

Reply With Quote
Reply

Similar Threads
Thread Thread Starter Forum Replies Last Post
Extracting data from XML file by PHP tarsius Programming Discussion 4 10-13-2011 01:48 AM
PHP, reading from an xml file Shib Programming Discussion 2 06-21-2010 03:03 PM
PHP, Mysql Fetch Error Help pcnet21 Programming Discussion 5 08-18-2006 01:31 PM
inserting data to mysql using php..from file? SFA-Dark Programming Discussion 3 01-26-2005 02:21 AM
Fetch info off a website and put it into a database - PHP/MYSQL mrsam Employment / Job Offers 4 10-31-2004 04:52 PM

Related posts from TheWhir.com
Title Type Date Posted
Panzura Offers Scality RING Organic Storage to Customers Web Hosting News 2011-12-14 20:10:15
Web Host Rackspace Launches Private Beta for MySQL Cloud Database Web Hosting News 2011-12-01 21:09:51
Web Host FireHost Partners with Cloud Security Firm Gazzang for Data Encryption Web Hosting News 2011-08-16 20:33:43
Web Host Servers Australia Deploys R1Soft Continuous Data Protection Web Hosting News 2011-06-27 20:02:15
Web Host WebHostingBuzz Partners with Cloud Platform SMEStorage Web Hosting News 2011-06-01 18:10:25


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?