Amazon web api - product search -page navigation not working
Posted: Sun Mar 04, 2007 2:27 am
feyd | Please use
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hi I am using php 5 amd apache2.
I am displaying product price for amazon. I am getting results for the first page but when I click next page again first page is getting displayed.
Please tell me what is the problem and my code is as follows:Code: Select all
<?php
// include class
require('c:/nusoap-0.7.2/lib/nusoap.php');
// create a instance of the SOAP client object
$soapclient = new soapclient("http://soap.amazon.com/schemas2/AmazonWebServices.wsdl",
true);
$category = 'DVD';
$searchtxt = 'Celtic Women';
$searchtxt = urlencode($searchtxt);
$page = 1;
$keyword = $searchtxt;
// create a proxy so that WSDL methods can be accessed directly
$proxy = $soapclient->getProxy();
// if a keyword is present, do a keyword search
$client = new soapclient("http://soap.amazon.com/schemas2/AmazonWebServices.wsdl", true);
$params = array(
'keyword' => $keyword,
'page' => $page,
'mode' => $category,
'type' => 'heavy',
'devtag' => '1448K5G6ZXH03DQ33W02'
);
$namespace = 'http://soap.amazon.com';
$action = 'http://soap.amazon.com';
$method = "KeywordSearchRequest";
$result = $client->call($method, array('KeywordSearchRequest' => $params),$namespace, $action);
$total = $result['TotalResults'];
$items = $result['Details'];
// format and display the results
?>
<html>
<head>
<basefont face="Verdana">
</head>
<body
bgcolor="white">
<p> <p>
<table width="100%"
border="0" cellspacing="5" cellpadding="0"> <?php
foreach ($items as $i)
{
?>
<tr>
<td
align="center" valign="top" rowspan="3"><a href="<?php echo $i['Url'];
?>"><img
border="0" src=<?php echo $i['ImageUrlSmall']; ?>></a></td>
<td><font
size="-1"><b><?php echo $i['ProductName']; ?></b> /
</font></td> </tr> <tr> <td align="left"
valign="top"><font
size="-1">List Price: <?php echo $i['ListPrice']; ?> /
Amazon.com Price: <?php
echo $i['OurPrice']; ?></font></td> </tr> <tr> <td
align="left"
valign="top"><font size="-1"><a href="<?php echo $i['Url'];
?>">Read more
about this title on Amazon.com</a></font></td> </tr> <tr>
<td
colspan=2> </td> </tr> <?php } ?> </table>
<!-- next and
prev page links -->
<?php
$pageCount = ceil($total/10);
?>
<table width="100%"
cellspacing="0" cellpadding="5">
<tr>
<td align="left"> <?php if ($page != 1) {?> <a href="<?php echo $_SERVER['PHP_SELF']; ?>?page=<?php echo $page - 1; ?>&keyword=<?php echo $keyword; ?>">Previous page</a> <?php } ?> </td>
<td align="center">Page <?php echo $page; ?> of <?php echo $pageCount; ?></td>
<?php for($i = 1; $i <= $pageCount; ++$i) ?>
<?php { ?>
<td align="right"> <a href="<?php echo $_SERVER['PHP_SELF']; ?> ?page=<?php echo $i ?> &keyword=<?php echo $keyword; ?> ">Next page</a> </td> <?php } ?>
</tr>
</table>
</body>
</html>feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]