Can you generate RSS feed for PHP personalized url script?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
glenn_obrien
Forum Newbie
Posts: 5
Joined: Sat Oct 03, 2009 5:55 am

Can you generate RSS feed for PHP personalized url script?

Post by glenn_obrien »

Hi,

I am new to the wonders of PHP, however, i have managed to created a script that allows me to generate personal URLs on my site from a simple csv file, for example, http://www.mysite.com/GlennOBrien. I have also managed to load a template file and content for each user from the csv file. Congrats i hear you say, however..... I am completely stuck on how to show an rss feed of each of the URLs that are opened. This will allow me to follow up and contact people who showed interest in the urls.

Is it possible to report this info? I an sure i can feed the info from the db, however, how can i tie this to the url?

Many thanks in advance!

Glenn
glenn_obrien
Forum Newbie
Posts: 5
Joined: Sat Oct 03, 2009 5:55 am

Re: Can you generate RSS feed for PHP personalized url script?

Post by glenn_obrien »

This is the code so far for the reader

Code: Select all

<?php
include 'config.php';
function fixamp($text){ 
    $newtext = str_replace("&", "&", $text);
    return $newtext;
}
//header("Content-Type: application/xml; charset=ISO-8859-1");  
header('Content-type: text/xml');
echo '<?xml version="1.0" ?>';
?>
<rss version="2.0">
 
<channel>
 
<title>PURL Report</title>
<description>Latest activity on the PURL system</description>
<link>http://fishandchipslondon.co.uk</link>
 
<?php
$ccount=0;
$nSQL = "SELECT * FROM tblentry WHERE username='".cleaninput($_GET['username'])."' ORDER BY entryid DESC LIMIT 1";
$resultn=mysql_query($nSQL)
  or die("Bad query! ".mysql_error());
while ($rown = mysql_fetch_array($resultn,MYSQL_ASSOC)) {
 
    
   $PurlName="#".$rown['comicid']." ".stripslashes(strip_tags(fixamp($rown['firstname'])));
   $PurlNumber=stripslashes(strip_tags(fixamp($rown['info1'])));
   
echo "<item>
<title>$PurlName/title>
<description>$PurlNumber</description>
</item>
    ";
}
?>
</channel>
 
</rss>
I also have an htacess file doing generating the urls:

Code: Select all

RewriteEngine on
RewriteBase /
RewriteRule ^([0-9a-zA-Z]+)/?$ ./profile.php?username=$1
RewriteRule purl.xml purl.php
 
The above is not showing a report for the urls accessed...

Any help would be very much welcomed as i am stuck in a hole on this!
glenn_obrien
Forum Newbie
Posts: 5
Joined: Sat Oct 03, 2009 5:55 am

Re: Can you generate RSS feed for PHP personalized url script?

Post by glenn_obrien »

Got it working,

thought i would post coded here incase others have the same problem

Code: Select all

 
 
$d=mysql_query('select * from tblentry')or die(mysql_error());
$LASTID=@mysql_num_rows($d); 
$total_user = mysql_num_rows(mysql_query("SELECT * FROM tblentry WHERE uni='yes'")); 
?>
<rss version="2.0">
<channel>
<title>User Report</title>
<description>Latest Users</description>
<link>http://fishandchipslondon.co.uk</link>
<?php 
echo "
<item>
<title>User Infos</title>
<description>
Total Unique Users: 
$total_user
</description>
</item>
";
$mSQL = "SELECT * FROM tblentry ORDER BY entryid DESC LIMIT 0,$LASTID"; 
$result=mysql_query($mSQL) or die("Bad query! ".mysql_error());
while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) {
$FIRST=$row['firstname'];
$LAST=$row['lastname'];
$USERNAME=$row['username'];
$COMPANY=$row['companyname'];
$UPDATE=$row['upload_date'];
$UNI=$row['uni'];
if($UNI=="yes"){
echo "
<item>
<title>$USERNAME</title>
<description>
<![CDATA[ 
FIRSTNAME : $FIRST 
LASTNAME : $LAST
COMPANY : $COMPANY
]]>
</description>
<link>http://fishandchipslondon.co.uk/$USERNAME</link>
<pubDate>$UPDATE</pubDate>
</item>
";
}
}
?>
 
 
Post Reply