LegionSmith Posted April 12, 2009 Share Posted April 12, 2009 Hi everyone, I have what is probably a very simple question. I have written a php script that creates an rss feed from mysql database values. I have everything working now but I need to setup the link for each "posting". What I'm trying to do is take the user id (which is what the profile url is, i.e. www.mysite.com/123) and append it to the url. Currently I have the base url (http://www.mysite.com) set as a variable and am trying to add $row['ID'] to it. $userid = $row['ID']; But, so far everything I've tried to do hasn't worked. There is no form being submitted so I'm assuming I can't use _GET. This is just a feed script that pulls all the needed info from peoples profiles in the database. Any help would be appreciated. Thanks, Michael Link to comment https://forums.phpfreaks.com/topic/153693-adding-mysql-value-to-url/ Share on other sites More sharing options...
MasterACE14 Posted April 12, 2009 Share Posted April 12, 2009 do you mean... <?php echo "http://www.mysite.com/page.php?userid=".$row['ID']; ?> ? Link to comment https://forums.phpfreaks.com/topic/153693-adding-mysql-value-to-url/#findComment-807690 Share on other sites More sharing options...
calmchess Posted April 12, 2009 Share Posted April 12, 2009 http://www.mysite.com/page.php?userid=<?php echo $row['ID'];?> Link to comment https://forums.phpfreaks.com/topic/153693-adding-mysql-value-to-url/#findComment-807696 Share on other sites More sharing options...
LegionSmith Posted April 12, 2009 Author Share Posted April 12, 2009 yeah, I had tried that. just tried it again. that doesn't work at all. here's a bigger snippet of my code. it's actually the entire function for the items portion of the xml file. private function getItems() { $itemsTable = "Profiles"; $this->dbConnect($itemsTable); $query = "SELECT * FROM ". $itemsTable; $result = mysql_db_query (DB_NAME, $query, LINK); $items = ''; while($row = mysql_fetch_array($result)) { $text = $row['ListingDescription']; $title = $row['ListingTitle']; $title2 = preg_replace(array('/</', '/>/', '/"/', '/&/'), array('<', '>', '"', '&'), $title); $text2 = preg_replace(array('/</', '/>/', '/"/', '/&/'), array('<', '>', '"', '&'), $text); $rsurl = 'http://www.mysite.com/'; $userid = $row['ID']; $link = rsurl ."". $userid; $items .= '<item> <title>'. $title2 .'</title> <link>'. $link .'</link> <description>'. $text2 .'</description> </item>'; } $items .= '</channel> </rss>'; return $items; Now, the variables $rsurl and $link are what I'm playing with at the moment. If I were to put $rsurl inside of the xml <link> tags then it works with the base url. But what I need is the base url plus the user id from the database for that particular person. We have a rewite rule script changing the url of the users profile from a long complex query to baseurl/user id. as in http://www.mysite.com/123. I hope that makes more sense, I would have thought this would have been simple, and I've tried several things, but it seems that something with the xml standards prevent alot of the normal php operations. for example, you can't seem to "echo $var" inside an xml tag as you'll just get the word echo. Thanks! Michael Link to comment https://forums.phpfreaks.com/topic/153693-adding-mysql-value-to-url/#findComment-807701 Share on other sites More sharing options...
LegionSmith Posted April 12, 2009 Author Share Posted April 12, 2009 Ok, so yeah. ultimately you were right. I just had to modify what you wrote a little bit. here's what worked: <link>'. "http://www.mysite.com/".$row['ID'] .'</link> Thanks again, I knew it was going to be a simple answer. Michael Link to comment https://forums.phpfreaks.com/topic/153693-adding-mysql-value-to-url/#findComment-807892 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.