我有获取远程 XML 文件并显示带有产品数据的表格的脚本。数据有以下格式:
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
+++++++++++++++++++
如您所见Name2
,ID 2 是相同的产品,但可以选择不同的月份和不同的价格。
我只需要显示一次相同的产品名称,并有一个带有月份选择的下拉菜单(因此价格将达到该菜单的值)
有人可以帮我写一些 PHP 函数吗?它不应该使用mysql数据库,也许是php数组......
非常感谢!
++++++++++++++++++++++++++++++++++++++++
非常感谢您的关注,非常感谢!Jan Turoň 的函数看起来是一个解决方案,但我很难实现它。这是我的实际代码:
<?
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;
?>
这是现场示例:http ://webservice.ge/eus/TestPHPAPIProductDetails.php
谢谢你的帮助!