Jump to content

how do i make a php rss feed with just one table?


emopoops

Recommended Posts

i have a mysql table with all the info on it.

well this is all the info: id, title, thepost, thedate, and the link.

now cant i make a rss feed with just that?

heres the link to one that explains how to do a rss with php:

http://www.webreference.com/authoring/languages/xml/rss/custom_feeds/

 

BUT. see how theres two tables there? i dont understand why i would need to make another much biger table akak the "web details" or whatevr its called table on that page.

 

can i do it with just the table i have? if so can i have some help? im confused. it seems like two tables it too much

Link to comment
Share on other sites

It all depends on what data you want the RSS to contain. An RSS feed can pretty much be structured to whatever you want displayed, so it really depends on your data.

 

I think the point of that deal is to help you understand how to structure an RSS feed with examples etc.

Link to comment
Share on other sites

You can do it with 1, 2, 20, 42, tables if you'd like. That's just how the tutorial creator decided to do it.

 

That said, I honestly can't see why he is using two tables either. It seems like he's creating a table to have just one row, because if there is more than one row that is retrieved, it will only take the last one anyway. Perhaps he meant to create a way to have multiple feeds, but got lazy halfway through? I'd find a different tutorial... but that's just me.

Link to comment
Share on other sites

You don't need the second table, but you do need some of the values which that example stores in the second table. The table you currently have contains the content/items which you wish to be dislpayed. The second table in that example stores the information relative to the channel/feed itself. Every valid RSS should contain a various channel information. You can find out about the different elements of an rss feed by clicking this link.

Link to comment
Share on other sites

alright people. thanks for the encouraging replies. but i need to know? what should i add to my existing table? or is this second table just have one row in it or something (feed info or whatever the poster above acalled it)

 

would i be pointless to add it to my existing table because the columsn would be blank for almost every entry? or is it something that is filled in with every feed post.

 

what i mean is that those other items in the table i do not want to make.... those items are optional. im asking if they only apear once on the feed? can i just make the copyright always be the (current year using date(Y) and can i just put the language  on their once or is it a reocuring thing like the description .

Link to comment
Share on other sites

Yes, as far as I can tell the table would only have one row, you could just as easily hardcode the information into your script. Yes it would be pointless to add to your current table because the table you have is for the 'syndicated' items, not for the actual feed/channel itself, the information would therefore be irrelevant to the information stored. The link I provided gives you exact information about the structure of a feed.

Link to comment
Share on other sites

ok i understand that now. but i have a link here:

http://www.ibm.com/developerworks/library/x-phprss/

 

there a re a few things i dont understnad. why do i need to use html entities?

 

why would the pub date be today? wouldnt it be the date i have stored in mysql for the item?

what is this limit 15? does that mean people can only read the latest 15 items on the feed? is that appropropriate? i dont think its appropriate to do all of them. that would probably be aweful if there were a lot. but is 15 too small of a number?

 

and again why do i need strip tags?

 

this is about the items im going to be using in this feed:

they are already displayed on my site homepage. and they have "bbcodes" put in. so do i just use the same include() thing i use on the homepage IN THIS RSS NOW to replac the bbcode with html that shows like bolds links etc... for the rss.php file im making?

 

and this rss.php file can this be read on feedreaders like every other .rss feed file? or is it different because its .php?

ALSO: can you put forms in rss items? like can i add a form to post the page variable so it can be "paginated" or does that not work on feed readers. or what?

Link to comment
Share on other sites

That script is probably using html entities and strip tags because if you didnt, you may get html tags in there which would make the rss feed invalid. Limit 15 will get the last 15 headlines from the sql database you are querying (as opposed to getting everything)

 

You DON'T want to put HTML in your rss feed, because that will make the rss feed invalid. Remember, XML and HTML are both markup languages, and thus both use tags. if you start using tags that are meaningless to rss readers, things will go haywire

 

It appears that passing the rss.php file into a feed reader will work because it sends the page as an xml file (via the header call)

Link to comment
Share on other sites

thanks.

i have one more question....

what about stripping the bbcodes? do ihave to make an include to strip those? like preg replace or something replace it will nothing. like instead of replacing the bbcodes () with (<b> < / b>) that kind of thing, i replace them with nothing? so i use the same thing and include it?

Link to comment
Share on other sites

BBCodes would mean nothing to an RSS feed reader, but then they also mean nothing to an HTML document. BBCodes are a method of allowing people to style data without allowing them the full use of HTML. Therefore in order to display a document you have to replace the BBTags with actual HTML. For an RSS feed, since it is an XML document, you cannot really use HTML in them so you will have to just strip them out.

Link to comment
Share on other sites

ok! i stripped them out and i have an almost valid feed! theres two things that are wrong: one of which i know how to fix sort of!

which function takes < and > out? its bothering me i cant figure it out.

 

the second one.. is here: http://validator.w3.org/feed/check.cgi?url=http%3A%2F%2Fwww.socialemo.com%2Frss.php its the xml thing i dont understand. i dont know why its not right its what it is in the tutorial!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.