Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
PHP and XML feed question
Old 09-30-2007, 05:43 PM PHP and XML feed question
Skilled Talker

Posts: 64
Trades: 0
I'm planning on making an XML feed for members to quickly access the latest updated threads on my website forum.

To be honest, I have rushed into it without reading many tutorials other than how to structure XML.

This is my code so far:

PHP Code:
<?php

$your_data 
"<?xml version=\"1.0\"?><rss version=\"2.0\"><channel><title>The Channel Title Goes Here</title><description>The explanation of how the items are related goes here</description><link>http://www.directoryoflinksgohere</link><item><title>The Title Goes Here</title><description>The description goes here</description><link>http://www.linkgoeshere.com</link></item></channel></rss>";

// Open the file and erase the contents if any
$fp fopen("feed.xml""w");

// Write the data to the file
fwrite($fp$your_data);

// Close the file
fclose($fp);

?>
In a fully-completed code, the $your_data variable would be a database output of the most recently updated threads.

My problem lies in that there are some boards on my forum that are hidden from members and are inaccessible to them and of course, I don't want those threads to be shown on the feed. However, they should be shown to SOME people, but not others.

By the system of coding I have above, I would include the above code on every page of my website so that everytime somebody loaded a page, the database would be queried and the feed would update.

- Could someone tell me if what I described above has a solution
and if
- I'm on completely the wrong track and where I can go to find the best information.

Last edited by Petsmacker; 09-30-2007 at 05:44 PM..
Petsmacker is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 10-01-2007, 05:13 PM Re: PHP and XML feed question
Super Talker

Posts: 130
Trades: 0
if i'm understanding you correctly, if someone can't view the page anyway, than they won't see the feed on that page.
__________________
flann

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
flann is offline
Reply With Quote
View Public Profile
 
Old 10-02-2007, 05:17 AM Re: PHP and XML feed question
maxxximus's Avatar
Extreme Talker

Posts: 219
Name: Rob
Location: UK
Trades: 0
You just need two feeds as I see it. One unfiltered available to secure level users only. A second feed available to all but with secure level threads filtered out.

The Xml file itself does not need to be written as this would produce a static Xml file with no dynamic capability. Just produce a php page with the recordset defined (SELECT FROM, mysql_query ,mysql_fetch_assoc etc) then to ensure its parsed as Xml the header should be defined :
Code:
// recordset here

// Start the RSS Feed

header('Content-type: text/xml'); // Must declare the content type
echo '<?xml version=\'1.0\' encoding=\'UTF-8\'?>';

// Set RSS version.

echo '
<rss version=\'2.0\'> ';

// Start the XML.

echo '
<channel><title>The forum title goes here</title>...<item>threads etc</item> </channel>
</rss>'
Works for me
maxxximus is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to PHP and XML feed question
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.11752 seconds with 12 queries