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

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
WHT Addict
 
Join Date: Sep 2009
Posts: 160

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
Untitled.png  



Sponsored Links
  #2  
Old
WHT Addict
 
Join Date: Sep 2009
Posts: 160
i'am still need help .

  #3  
Old
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.

Sponsored Links
  #4  
Old
WHT Addict
 
Join Date: Sep 2009
Posts: 160
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

  #5  
Old
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

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
Tesora's OpenStack DBaaS Supports MongoDB, Cassandra, Redis, and MySQL Web Hosting News 2014-05-23 14:53:11
Google Releases Hosted Database Service Cloud SQL to General Availability Web Hosting News 2014-02-12 13:46:02
AeroFS Launches Private File Sharing Software Web Hosting News 2013-11-22 17:00:53
Google Cloud Provides Support For Native MySQL Connections Web Hosting News 2013-11-01 14:36:06
Egnyte Launches Program to PRISM-Proof Enterprise Cloud File-sharing Web Hosting News 2013-09-27 13:45:48


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?
WHT Host Brief Email:

We respect your privacy. We will never sell, rent, or give away your address to any outside party, ever.

Advertisement:
Web Hosting News:
WHT Membership
WHT Membership



 

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?