the-ferret
17-08-08, 21:05
OK guys a bit noddy but will share it anyway in case it helps as took me an hour or so of playing to get this far. I wanted to be able to search and then display the output in a table along with a count of products. Used the example from AW website and hadn't come across objects or OOP PHP b4 so took me a while (clearly I am not worthy and apologies to all the experienced php developeers here that have not posted examples :p )
<?php
$aParams7 = array("sQuery" => "ferret", "bAdult" => False, "iLimit"=>10, "sSort" => "relevancy");
$oResponse= $oClient->call('getProductList', $aParams7);
echo "We found ".$count." products<br>";
echo"Here are the 1st 10<BR><BR>";
echo"<table>";
foreach($oResponse->oProduct as $details){
$name = $details->sName;
$price = $details->fPrice;
$image = $details->sAwThumbUrl;
echo "<tr><td>".$name."</td><td>".$price."</td><td><img src='".$image."'></td></tr>";
}
echo "</table>";
?>
As you can see, easy to add the deeplink to make it into a link to the merchants website. I tried to echo the object directly e.g. echo $details->sName but that did not work for me hence ended up assigning to a variable. Google search suggested that this should work - echo {$details->sName} but could not get that working on my php5 install.
<?php
$aParams7 = array("sQuery" => "ferret", "bAdult" => False, "iLimit"=>10, "sSort" => "relevancy");
$oResponse= $oClient->call('getProductList', $aParams7);
echo "We found ".$count." products<br>";
echo"Here are the 1st 10<BR><BR>";
echo"<table>";
foreach($oResponse->oProduct as $details){
$name = $details->sName;
$price = $details->fPrice;
$image = $details->sAwThumbUrl;
echo "<tr><td>".$name."</td><td>".$price."</td><td><img src='".$image."'></td></tr>";
}
echo "</table>";
?>
As you can see, easy to add the deeplink to make it into a link to the merchants website. I tried to echo the object directly e.g. echo $details->sName but that did not work for me hence ended up assigning to a variable. Google search suggested that this should work - echo {$details->sName} but could not get that working on my php5 install.