Bravat Posted January 29, 2011 Share Posted January 29, 2011 I had to create a custom search for OpenCart (with multiple drop down lists), and now i need to create a custom pagination. Code is working fine until i click next or page number, then I get errors (it is the same like when you go directly to search page without submitting search query (Undefined index: Rim in... and it list all the indexes)). This is part of the drop down lists: <form id="form1" name="form1" method="post" action="index.php?route=product/search"> <input type="text" value="keyword" id="filter_keyword" name="keywords" onclick="this.value = '';" onkeydown="this.style.color = '000000'" style="color: #999;width:154px;"> <?php $result = mysql_query("SELECT * FROM product GROUP BY Rim"); ?> <select id="Rim" name="Rim" selected="selected" style="width:158px;position:static;z-index:-1;"> <option value="rim" selected="selected"><?php echo "Rim"; ?></option> <?php while ($row = mysql_fetch_array($result)) { echo "<option>" . $row['Rim'] . "</option>"; echo "<br />"; } ?> </select> ..... <input type="submit" name="Kreni" value="Pretrazi" /> and this is pagination part (where search is routed): $per_page = 4; if(isset($_POST['Pretrazi'])){ $start = $_POST['start'];} $result = mysql_query($query) or die("Couldn't execute query"); $record_count = mysql_num_rows($result); $max_pages = $record_count / $per_page; $start = 0; $query .= "LIMIT $start, $per_page"; $result = mysql_query($query); echo "<p>You searched for: <br> "" . $rimp . " " . $dimenzijap . $sezona . " "</p><hr>"; if($result && mysql_num_rows($result) > 0) { $i = 0; $max_columns = 4; ?><table class="tabela"><?php while($row = mysql_fetch_assoc($result)) { $title = $row["Rim"]; $model = $row["model"]; $dimenzija = $row["Dimenzija"]; $ime = $row['name']; $cena = $row['price']; $cena = number_format($cena, 2, ',', '.'); $id = $row['product_id']; if($i == 0) echo "<tr>"; echo "<td>" ?><a href="index.php?route=product/product&product_id=<?php echo $id?>"><?php echo $model ?></a> <?php echo "<br>$dimenzija<br>$ime<br>"; ?> <span style="color: #900; font-weight: bold;"><?php echo $cena . "din"?> </span> <?php echo "</td>"; if(++$i == $max_columns) { echo "</tr>"; $i=0; } }} if($i > 0) { for($j=$i; $j<$max_columns;$j++) echo "<td> </td>"; echo "</tr>"; } ?> </table> <?php $prev = $start - $per_page; $next = $start + $per_page; ?> <table width="100%" border="1"> <tr><td><?php if (!($start<=0)){ echo "<a href='index.php?route=product/search&start=$prev'>Prev </a>"; } $page = 1; for($x=0;$x<$record_count;$x=$x+$per_page){ echo " <a href='index.php?route=product/search&start=$x'> $page </a> "; $page++; } if (!($start>=$record_count - $per_page)){ echo "<a href='index.php?route=product/search&start=$next'> Next</a>"; } ?></td> </tr> </table> What seems to be the problem? Quote Link to comment https://forums.phpfreaks.com/topic/226078-problem-with-opencart-and-pagination/ Share on other sites More sharing options...
Bravat Posted January 29, 2011 Author Share Posted January 29, 2011 One quick question. Why when i change method to GET it doesn't do anything (it basically stay on home page) Quote Link to comment https://forums.phpfreaks.com/topic/226078-problem-with-opencart-and-pagination/#findComment-1167063 Share on other sites More sharing options...
waseem Posted April 9, 2011 Share Posted April 9, 2011 Your request method is POST. please check page count form your error. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/226078-problem-with-opencart-and-pagination/#findComment-1199110 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.