Jump to content

Creating RSS/XML File from PHP and Mysql


shane85

Recommended Posts

hey guys

 

gonna give a brief rundown of what im trying to do. Basically, im using a software for tv screens that can point to any rss file and will display the rss on tv screens as a "ticker" very similar to cnn. What I am trying to achieve is through my website, have someone who has these screens in their facility log in, be able to update this "ticker" file, and have the software that is pointing to this file read and display the new ticker.

 

im new to php but I already have it set up so that users can log in, and update the ticker in mysql..now I need to somehow convert this to rss...I have been browsing on the web and a snipet of coding that I found to have worked is below...I tried pointing the software at the file for it and appeared to work...it is as follows

 

<rss version="2.0">

<channel>

    <title>Test Title</title>

    <description>This is an example description</description>

    <link>http://pixel2life.com</link>

 

<?

 

$sql = "SELECT * FROM news limit 5";

// $sql = "SELECT ticker FROM host_locations WHERE location_id='$location_id' "; This is the query that I tried adding since im trying to select the ticker from host_locations and make sure that it is the right one by using WHERE location_id='$location_id'";

 

 

$result = mysql_query($sql);

while($row = mysql_fetch_assoc($result)){

?>

 

<item>

    <title><?=$row['title']; ?></title>

    <author><?=$row['author']; ?></author>

    <link>http://MYSITE.com/news.php?id=<?=$row['id']; ?></link>

</item>

 

<?

}

?>

 

</channel>

</rss>

 

the script that I initialyl took this from in the db had 4 fields - id, title, author, content

 

now I already have a "ticker" row in my table host_locations and really, I dont think I need the other stuff because I already have the stuff I need in my host_location table (id) anyway...I dont need to have author, content, title etc. used really I just need to have content used so it just displays the text thats in the ticker row. Everything ive tried isnt working and even using the code from the initial script I had it working, howver it displays it in rows etc just like a rss file...is there a way so it doesnt display it like this??? All I want to be shown is the text...I have it within a tv image scrolling in a marquee so it resembles what it would look like. Any help would be greatly appreciated

Link to comment
Share on other sites

By the sound of it you don't want it in an RSS feed just plain text pm the page if so just remove the rss stuff and use the php

 

<?

$sql = "SELECT * FROM news limit 5";
// $sql = "SELECT ticker FROM host_locations WHERE location_id='$location_id' "; This is the query that I tried adding since im trying to select the ticker from host_locations and make sure that it is the right one by using WHERE location_id='$location_id'";


$result = mysql_query($sql);
while($row = mysql_fetch_assoc($result))
{
   echo $row['content'];      
}
?>

Link to comment
Share on other sites

well to be honest I dont even care about displaying the rss...im perfectly happy just displaying the normal txt however the software im using in order for the ticker to scroll proprely needs to point at an rss file...what would be the best way to achieve this? If I already have txt being stored in my db under the row "ticker"...how can I have that txt be converted into an rss file that is unique to that login, so that the software can point to it? And also, everytime that row in the database is updated, the rss file is updated

Link to comment
Share on other sites

actually I guess I need just the title field to be displayed...I setup the script exactly like that tutorial showed and when I point my software to the link it displays it and scrolls it as

 

Title 3 -- Title 2 -- Title 1 --

 

doesnt show any of the content oranything....so I guess I just need to display the title field...how can I achieve this? Again, this webpage wont even need to be accessed by anyone online, rather just have the software pointed at it so it can scroll on the screens....is there a way to set it up so it doesnt have tables with "RSS FEED" in yellow at the top and all of it done in tables....ideally I would just like to display just the text on the page, nothing else what so ever

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.