Jump to content

RSS PHP Help


sullyman

Recommended Posts

Hi Folks,

 

I have created an RSS feed and the following calls a data value successfully from mysql

 

$veh["year"]="int_1";

$veh["make"]="vmake";

$veh["model"]="vmodel";

 

For the title, i would like to call three different fields to make one title. Is this possbile?

e.g.

$veh["title"]="int_1+vmake+vmodel";

 

Thanks,

S

Link to comment
https://forums.phpfreaks.com/topic/138580-rss-php-help/
Share on other sites

Sorry guys. Here is the code below. I need it to extract listings to place on Oodle.com

 

I can't get the following line to work to add Year+Make+Model together for the Title. Everything else works great.

 

$vehicles_oodle["title1"]=$veh["int_1"].$veh["v_255_9"].$veh["v_255_10"];

 

<?php
//settings section

$vehicles_oodle=array();
$vehicles_oodle["id"]="link_id";
        $vehicles_oodle["url"]="http://www.mysite.com/index.php?page=out&id=#link_id";
$vehicles_oodle["title"]="v_title";
        $vehicles_oodle["title1"]=$veh["int_1"].$veh["v_255_9"].$veh["v_255_10"];
$vehicles_oodle["year"]="int_1";
$vehicles_oodle["make"]="v_255_9";
$vehicles_oodle["model"]="v_255_10";
        $vehicles_oodle["body_type"]="v_255_1";
        $vehicles_oodle["color"]="v_255_15";
        $vehicles_oodle["fuel_type"]="v_255_4";
        $vehicles_oodle["mileage"]="int_2";
$vehicles_oodle["price"]="v_price";
$vehicles_oodle["description"]="v_descr";
$vehicles_oodle["expire_time"]="exp_date";
$vehicles_oodle["city"]="v_255_14";
$vehicles_oodle["image_url"]="images";	

$feed_oodle=array();
$feed_oodle["filename"]="oodle.xml";	
$feed_oodle["vehicles"]=$vehicles_oodle;
$feed_oodle["vehicles_id"]=960;
$feed_oodle["vehicles_category"]="Vehicles";
$feed_oodle["vehicles_category_tag"]="category";

$feeds=array();
$feeds[]=$feed_oodle;

//settings section***

//function section
function dbConnect($host, $user, $password, $name)
{
	$connection = mysql_connect($host, $user, $password);
	mysql_select_db($name, $connection);
}

function saveXmlTag($fp,$tag,$category,$category_tag,$fields,$values) {
	$data="<$tag>\r\n";

	$category=str_replace("&","&",$category);
	$category=str_replace("<","<",$category);
	$category=str_replace(">",">",$category);
	$data.="  <$category_tag>$category</$category_tag>\r\n";

	foreach ($fields as $current_field=>$current_value) {
		if (strpos($current_value,"#link_id")) {
			$value=str_replace("#link_id",$values["link_id"],$current_value);
		} else {
			if ($current_value=="images") {
				$value=$values[$current_value];
				if ($value!="") {
					if (strpos($value,"\n")) {
						$value=substr($value,0,strpos($value,"\n"));
					}
					$value="http://www.mysite.com/files/".$value;
				}
			} else {
				$value=$values[$current_value];
			}
		}

		$value=utf8_encode(htmlspecialchars($value));

		$data.="  <$current_field>".$value."</$current_field>\r\n";
	}

	$data.="  <country>US</country>\r\n";
              

	$data.="</$tag>\r\n";
  	fputs($fp,$data);
		unset($data);		
}	

function saveCategory($feed_fields,$feed_id,$feed_category,$category_tag,$fp) {
	$sql = "select * from table_ad where catid=$feed_id order by link_id";
	$result = mysql_query($sql);
	while ($record = mysql_fetch_assoc($result)) {
		saveXmlTag($fp,"listing",$feed_category,$category_tag,$feed_fields,$record);
	}
	mysql_free_result($result);
}

//function section***	


//main section
dbConnect($dbSettings["host"], $dbSettings["user"], $dbSettings["password"], $dbSettings["name"]);

foreach ($feeds as $feed_item) {
	$filename=$feed_item["filename"];

 	$fp = fopen($xmlDir.$filename,'w');
 	$data='<?xml version="1.0" encoding="ISO-8859-1"?>'."\r\n";		
	$data.='<listings>'."\r\n";
		fputs($fp,$data);
		unset($data);


	//vehicles
		saveCategory($feed_item["vehicles"],$feed_item["vehicles_id"],$feed_item["vehicles_category"],$feed_item["vehicles_category_tag"],$fp);





	$data='</listings>'."\r\n";
		fputs($fp,$data);
		unset($data);
		fclose($fp);
}

//main section***	
?>

Link to comment
https://forums.phpfreaks.com/topic/138580-rss-php-help/#findComment-724825
Share on other sites

Not sure what to say..

Okay your need to read the values in before you can use them..

if you just want

int_1 v_255_9v_255_10

then set that

ie

$vehicles_oodle["title1"]="int_1 v_255_9v_255_10";

 

if your reading them in then concat them after reading them in

ie

$vehicles_oodle["title1"]=$veh["int_1"].$veh["v_255_9"].$veh["v_255_10"];

 

who wrote the code ?

Link to comment
https://forums.phpfreaks.com/topic/138580-rss-php-help/#findComment-724871
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.