Jump to content

Making my title a link


nicky666
Go to solution Solved by nicky666,

Recommended Posts

Hi

 

I'm trying to create a rss feed and I would like to make the title the link that goes to its respective news. When I add the <a> tags everything disappears but it shows up in the page source and if I remove the <a> tags the it shows up in the web page but the title doesn't link to anything.

	<?php
	ini_set('display_errors', 1);
	header("Content-type: text/xml");
	include("config.php");
	global $NEWS;
	$str = '<?xml version="1.0" encoding="UTF-8"?>';
	$str.= '<rss version="2.0">';
	$str.='<channel>';
	$sql = "SELECT * FROM $NEWS";

	$result = mysql_query($sql) or die ($sql."".mysql_error());

	while($row = mysql_fetch_object($result)){
	    $str.= '<item>';
		$str.='	<a href="'.getSEOLink(13).'&article='.$row->id.'">';
	    $str.= '<title>'.$row->title.'</title></a>';
	    $str.= '<description><![CDATA['.$row->content. ']]></description>';
	    $str.= '</item>';
	}

	$str .='</channel>';
	$str .='</rss>';
	echo $str;
	?>
Link to comment
Share on other sites

  • Solution

I finally got it to work.

I had to remove the <a> tags and put <link> elements in and the I had to remove the & and put in &

 

Here is my code so that someone else can understand what I mean.

<?php
ini_set('display_errors', 1);
header("Content-type: text/xml");
include("config.php");
global $NEWS;
$str = '<?xml version="1.0" encoding="UTF-8"?>';
$str.= '<rss version="2.0">';
$str.='<channel>';
$sql = "SELECT * FROM $NEWS";

$result = mysql_query($sql) or die ($sql."".mysql_error());

while($row = mysql_fetch_object($result)){
    $str.= '<item>';
    $str.= '<title>'.$row->title.'</title>';
    $str.= '<link>'.getSEOLink(13).'&article='.$row->id.'</link>';
    $str.= '<description><![CDATA['.$row->content. ']]></description>';
    $str.= '</item>';
}

$str .='</channel>';
$str .='</rss>';
echo $str;
?>
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.