rss feed xml to php

I’m using a rss feed to display products.
I’m pretty new to php.

I need to be able to display 3 different categories
. sports brands
. clothing
. gifting

302231 Gifting Drinkware Flasks 1.8l Plastic Vacuum Flask BW0042
  • 18/8 Stainless Steel
  • 225ml Capacity
  • Twist Top
  • Hinged Metal Safety Lid Connector
38305_Thumb.png

I’m using the following script to extract info
I’ve only ever worked sql statemtents.

$html = “”;
$url = “http://www.kevro.co.za/rss/[email protected]&password=guykaimowitz&feed=product”;
$xml = simplexml_load_file($url);
for($i = 0; $i < 5; $i++) {
$id = $xml->product[$i]->id;
$categorygroup = $xml->product[$i]->categorygroup;
$category = $xml->product[$i]->category;
$group = $xml->product[$i]->group;
$name = $xml->product[$i]->name;
$code = $xml->product[$i]->code;
$description = $xml->product[$i]->description;
$thumb = $xml->product[$i]->thumb;
$html .= “

$id
$categorygroup
$category
$group
$name
$code

$description

$thumb
”;
}
echo $html;

How can I display $categorygroup with the value gifting only
or
How can I display $categorygroup with the value clothing only
or
How can I display $categorygroup with the value sports brands only

first off, you should never post your password(s) on a public forum, instead, replace it with a bunch of xxxx’s or something…
I would advise after reading this post, you go off and change your password for the rss feed in question.

Now, with that out the way, let’s fix you up…

Replace this line:
[php]$html .= “

$id
$categorygroup
$category
$group
$name
$code

$description

$thumb
”;[/php]

with this:
[php]
// only get clothing and gifting.
if($categorygroup == ‘Gifting’ || $categorygroup == ‘Clothing’) {
$html .= “

$id
$categorygroup
$category
$group
$name
$code

$description

$thumb
”;
}[/php]

Hope that helps,
Red :wink:

[u][b]Thank you for your response, however I think I require another solution.

I have the following code:
[/b][/u]

<?php session_start(); $group = ""; include("connection/connection.php"); if(isset($_REQUEST["group "])) $group = $_REQUEST["group "]; $sql = "SELECT * FROM `products` WHERE `group ` LIKE '" . $group . "' AND `new_status` LIKE 'show' LIMIT 0 , 150"; $result = mysql_query($sql) or die(mysql_error("Search of property failed")); $num = mysql_numrows($result); if($num == 0) { header("Location: products.php?message=Not_Found"); echo "SORRY Listing with Ref " . $ref . " could not be found"; exit(); } $i = 0; $id = mysql_result($result, $i, "id"); $code = mysql_result($result, $i, "code"); $group = mysql_result($result, $i, "group "); $product_title = mysql_result($result, $i, "product_title"); $product_image = mysql_result($result, $i, "product_image"); $product_supplier = mysql_result($result, $i, "product_supplier"); switch ($group ) { case "Active Wear": $outerframe = "2300"; break; case "Tracksuit": $outerframe = "2300"; break; case "T Shirts": $outerframe = "2950"; break; case "Sweater": $outerframe = "2300"; break; case "Lounge Shirt": $outerframe = "12100"; break; case "Jacket": $outerframe = "4700"; break; case "Headwear": $outerframe = "2900"; break; case "Workwear": $outerframe = "3350"; break; case "Kiddies Collection": $outerframe = "2300"; break; case "Jersey": $outerframe = "2300"; break; case "Golf Shirt": $outerframe = "10600"; break; case "Fleece": $outerframe = "2300"; break; case "Corporate Wear": $outerframe = "2300"; break; case "Trousers": $outerframe = "2300"; break; case "Bags": $outerframe = "13900"; break; case "Ladies Gifts": $outerframe = "2300"; break; case "Hampers": $outerframe = "7500"; break; case "Carrol Boyes": $outerframe = "3000"; break; case "Writing Instruments": $outerframe = "12100"; break; case "Tools": $outerframe = "4300"; break; case "Office Accessories": $outerframe = "9600"; break; case "Novelties": $outerframe = "8200"; break; case "Leisure and Outdoor": $outerframe = "13900"; break; case "Folders and Notebooks": $outerframe = "6450"; break; case "Drinkware": $outerframe = "5050"; break; case "Out of Africa": $outerframe = "3000"; break; case "BRT": $outerframe = "2300"; break; case "Acelli": $outerframe = "2300"; break; } $backgroundCentreHeight = $outerframe - 444; ?>

Which works fine.

I’m now being forced to switch to a RSS Feed as the client wishes to display multiple suppliers on his website.

$html = “”;
$url = “http://www.kevro.co.za/rss/products.aspx?email=xxxx&password=xxxx&feed=product”;
$xml = simplexml_load_file($url);
for($i = 0; $i < 5; $i++) {
$id = $xml->product[$i]->id;
$categorygroup = $xml->product[$i]->categorygroup;
$category = $xml->product[$i]->category;
$group = $xml->product[$i]->group;
$name = $xml->product[$i]->name;
$code = $xml->product[$i]->code;
$description = $xml->product[$i]->description;
$thumb = $xml->product[$i]->thumb;

$html .= "<div>$id - $categorygroup - $category - $group - $name - $code<br /><br />$description<br /><br />$thumb</div>
<hr /><br /><br />";

}
echo $html;

So I’m trying extract values in the “$group” that are the same as whatever the value is in the $group = $_REQUEST["group "];

Sponsor our Newsletter | Privacy Policy | Terms of Service