I have script which fetches remote XML file and displays table with product data. data has following format:
ID, name, price, months.
+++++++++++++++++++
1, Name1, $24, 12
2, Name2, $11, 24
2, Name2, $10, 36
3, Name3, $16, 12
2, Name2, $9, 48
4, Name4, $26, 12
+++++++++++++++++++
as you see Name2
with ID 2 are same product, but with choice of different months and different price.
I need to display same product name only once and have a drop-down menu for it with the month choice (so the price will go to that menu's value)
Can anybody help me writing some PHP function for it? It shouldn't use mysql database, maybe php arrays...
Thank you very much!
++++++++++++++++++++++++++++++++++++
Thanks so much for your attention, really appreciating this! Function by Jan Turoň looks as a solution, but I have trouble to implement it.. here's my actual code:
<?
try
{
$client = new soapclient("https://api.thesslstore.com/WBService.svc?wsdl", array('trace' => 1,'soap_version' => SOAP_1_1));
$parameters = array('objAuth'=>array("ResellerUserName"=>"user@domain.net","ResellerPassword"=>"password","PartnerCode"=>000000111));
// get the result, a native PHP type, such as an array or string
$result = $client->GetAllProductPrice($parameters);
$counter=count($result->GetAllProductPriceResult->AllProductPrice->AllProductPricing);
for ( $i=0; $i<$counter; $i+=1) {
printf("<tr><td> %s \n", $result->GetAllProductPriceResult->AllProductPrice->AllProductPricing[$i]->NumberOfMonths ."</td>");
printf("<td> %s \n", $result->GetAllProductPriceResult->AllProductPrice->AllProductPricing[$i]->Price ."</td>");
printf("<td> %s \n", $result->GetAllProductPriceResult->AllProductPrice->AllProductPricing[$i]->ProductCode ."</td>");
printf("<td> %s \n", $result->GetAllProductPriceResult->AllProductPrice->AllProductPricing[$i]->ProductName ."</td>");
}
catch (Exception $e)
{
printf("Error:sendSms: %s\n",$e->__toString());
}
exit;
?>
And here's the live example: http://webservice.ge/eus/TestPHPAPIProductDetails.php
Thanks for your help!