Hi,
a database have 4 feilds, book_id autofull , book_title varchar(255), book_desc text, and book_author .. i need to do is to show all listings in htis category in xml format, primary key can be book_title :)
can any one help me :)
Printable View
Hi,
a database have 4 feilds, book_id autofull , book_title varchar(255), book_desc text, and book_author .. i need to do is to show all listings in htis category in xml format, primary key can be book_title :)
can any one help me :)
Very easy - depends on your intended XML output structure though.
Something like this should get you started
Should be able to adapt that to your XML structure :)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; ?>
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 ?
just change the query
PHP Code:$books = mysql_query(select * from `books` where `author` = \''.$_GET['bookauthor'].'\'');
1 thing please :) do i need XML headers i mean starting from <xml> tag.. do i need to put these headers in echo""; ???
Send an XML mime type:
And add the XML declaration:Code:header('Content-Type: application/xml');
Code:<?xml version="1.0" encoding="UTF-8"?>
and in botton /xml right ?
No. The XML prolog is separate from the root node.
Here is an example of a complete XML document.
The child node is unnecessary, I put it in simply for the purpose of an example.Code:<?xml version="1.0" encoding="utf-8"?>
<root-node>
<child-node />
</root-node>