I have a long XML data file with 500+ elements in it:
<?xml version="1.0" encoding="ISO-8859-1"?>
<CATALOG>
<ITEM>
<TITLE>ITEM name</TITLE>
<TYPE>TYPE </TYPE>
<DESCIPTION>DESCIPTIONiliate Page CPM</DESCIPTION>
<PRICE>PRICE</PRICE>
<ITEM>http://mysite.com/item-link</ITEM>
</ITEM>
</CATALOG>
and I use the following code on the php page to import data from an XML file:
<?php
$ITEMSS = new SimpleXMLElement('ITEMS.xml', null, true);
echo <<<EOF
<table width="100%" align="center" border="1" bordercolor="#0099ff" cellpadding="1" cellspacing="0">
<tr>
<th bgcolor="#66ccff"><span class="style4">ITEM Name</span></th>
<th bgcolor="#66ccff"><span class="style4">item TYPE </span></th>
<th bgcolor="#66ccff"><span class="style4">item DESCIPTION </span></th>
<th bgcolor="#66ccff"><span class="style4">item PRICE</span></th>
<th bgcolor="#66ccff"><span class="style4">link to item</span></th>
</tr>
EOF;
foreach($ITEMSS as $ITEMS)
{
echo <<<EOF
<tr height="30" align=middle>
<td><a href="{$ITEMS->ITEM}" target="_blank"><span class="STYLE7">{$ITEMS->TITLE}</span></a></td>
<td><span class="STYLE8">{$ITEMS->TYPE}</span></td>
<td><span class="STYLE8">{$ITEMS->DESCIPTION}</span></td>
<td><span class="STYLE8">{$ITEMS->PRICE}</span></td>
<td><a href="{$ITEMS->ITEM}" target="_blank"><B><span class="STYLE7">cHECK IT OUT</span></B></a></td>
</tr>
EOF;
}
echo '</table>';
?>
I need to add an if statement in the loop to select only some data, if the TYPE has a specific value, it will show this data if it does not skip it.
It is also necessary to add a swap system, since there will be more than 500 elements in the list, I want the minimum number of elements to be shown in the table, saying 25.
Thanks guys for your help!
source
share