001.
<html>
002.
<head>
003.
<title>ThaiCreate.Com Tutorial</title>
004.
</head>
005.
<body>
006.
<?
007.
error_reporting(E_ALL);
008.
$apiKey =
'78b0db8a-0ee1-4939-a2f9-d3cd95ec0fcc'
;
009.
$trackingid =
'7000610'
;
010.
$keyword =
'laptops'
;
011.
$categoryId =
'9007'
;
012.
$numItems =
'10'
;
013.
$numOffers =
'10'
;
015.
016.
$apicall =
"$endpoint?apiKey=$apiKey"
017.
.
"&trackingId=$trackingid"
018.
.
"&categoryId=$categoryId"
019.
.
"&numItems=$numItems"
020.
.
"&showProductOffers=true"
021.
.
"&numOffersPerProduct=$numOffers"
022.
.
"&showProductReviews=true"
023.
.
"&numReviewsPerProduct=3"
;
024.
025.
026.
$resp = simplexml_load_file($apicall);
027.
$Num_Rows = intval($resp->categories->category->items[
'returnedItemCount'
]);
028.
029.
$Per_Page = 4;
030.
031.
$Page = $_GET[
'Page'
];
032.
if
(!$_GET[
'Page'
])
033.
{
034.
$Page=1;
035.
}
036.
037.
$Prev_Page = $Page-1;
038.
$Next_Page = $Page+1;
039.
040.
$Page_Start = (($Per_Page*$Page)-$Per_Page);
041.
if
($Num_Rows<=$Per_Page)
042.
{
043.
$Num_Pages =1;
044.
}
045.
else
if
(($Num_Rows % $Per_Page)==0)
046.
{
047.
$Num_Pages =($Num_Rows/$Per_Page) ;
048.
}
049.
else
050.
{
051.
$Num_Pages =($Num_Rows/$Per_Page)+1;
052.
$Num_Pages = (
int
)$Num_Pages;
053.
}
054.
$Page_End = $Per_Page * $Page;
055.
IF ($Page_End > $Num_Rows)
056.
{
057.
$Page_End = $Num_Rows;
058.
}
059.
060.
echo
"<table border=\"0\" cellspacing=\"1\" cellpadding=\"1\"><tr>"
;
061.
$intRows = 0;
062.
for
($i=$Page_Start;$i<$Page_End;$i++)
063.
{
064.
echo
"<td>"
;
065.
$intRows++;
066.
067.
$name =($resp->categories->category->items->product[$i]->name);
068.
$images = ($resp->categories->category->items->product[$i]->images->image[0]->sourceURL);
069.
070.
071.
$n =$i+1;
072.
073.
echo
"<center>$n<img src=\"$images\"><br> $name<br> </center>"
;
074.
echo
"</td>"
;
075.
if
(($intRows)%2==0)
076.
{
077.
echo
"</tr>"
;
078.
}
079.
}
080.
echo
"</tr></table>"
;
081.
?>
082.
083.
<br>
084.
Total <?= $Num_Rows;?> Record : <?=$Num_Pages;?> Page :
085.
<?
086.
if
($Prev_Page)
087.
{
088.
echo
" <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page'><< Back</a> "
;
089.
}
090.
091.
for
($i=1; $i<=$Num_Pages; $i++){
092.
if
($i != $Page)
093.
{
094.
echo
"[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i'>$i</a> ]"
;
095.
}
096.
else
097.
{
098.
echo
"<b> $i </b>"
;
099.
}
100.
}
101.
if
($Page!=$Num_Pages)
102.
{
103.
echo
" <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page'>Next>></a> "
;
104.
105.
}
106.
107.
?>
108.
109.
110.
</body>
111.
</html>