|
-
Apr 10th, 2006, 12:32 PM
#1
Thread Starter
Addicted Member
-
Apr 11th, 2006, 08:14 AM
#2
Re: Expanding Database Results into PHP
Very easy - depends on your intended XML output structure though.
Something like this should get you started
PHP Code:
<?php
$books = mysql_query('select * from `books`');
while ($book = mysql_fetch_assoc($books)):
?><book id="<?=$book['book_id']?>">
<title><?=$book['book_title']?></title>
<author><?=$book['author']?></author>
<description><?=$book['book_desc']?></description>
</book>
<?php endwhile; ?>
Should be able to adapt that to your XML structure
-
Apr 12th, 2006, 05:20 AM
#3
Thread Starter
Addicted Member
Re: Expanding Database Results into PHP
sorry but is it possible like
if some one use http://www.domain.com/abcxml.php?bookauthor=ABC
when some one use XML results retriving cod ewith above url, will it be working ?
-
Apr 12th, 2006, 08:34 AM
#4
Re: Expanding Database Results into PHP
just change the query
PHP Code:
$books = mysql_query(select * from `books` where `author` = \''.$_GET['bookauthor'].'\'');
-
Apr 13th, 2006, 02:08 AM
#5
Thread Starter
Addicted Member
Re: Expanding Database Results into PHP
1 thing please do i need XML headers i mean starting from <xml> tag.. do i need to put these headers in echo""; ???
-
Apr 13th, 2006, 05:21 AM
#6
Re: Expanding Database Results into PHP
Send an XML mime type:
Code:
header('Content-Type: application/xml');
And add the XML declaration:
Code:
<?xml version="1.0" encoding="UTF-8"?>
-
Apr 14th, 2006, 09:02 AM
#7
Thread Starter
Addicted Member
Re: Expanding Database Results into PHP
and in botton /xml right ?
-
Apr 14th, 2006, 09:12 AM
#8
Re: Expanding Database Results into PHP
No. The XML prolog is separate from the root node.
Here is an example of a complete XML document.
Code:
<?xml version="1.0" encoding="utf-8"?>
<root-node>
<child-node />
</root-node>
The child node is unnecessary, I put it in simply for the purpose of an example.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|