hi all
i m using pagination to show my products results according to particular category.
it shows
but when i click these links then these links dont show next and prev results of particular category i m on.
Like i m on nokia category. Then on clicking the next buton or prev buton , these butons show result of samsung or lg which are my prev and next categories.
i want to show results of next and prev products in nokia category. -
<?php
-
$dealer_id=$_REQUEST['dealer_id'];
-
$category_id=$_REQUEST['category_id'];
-
$limit=3; // rows to return
-
$qry="select * from product_table where dealer_id=$dealer_id";
-
$result=mysql_query($qry);
-
$row=mysql_fetch_array($result);
-
$numrows=mysql_num_rows($result);
-
-
// next determine if offset has been passed to script, if not use 0
-
if (empty($offset)) {
-
$offset=0;
-
}
-
-
// get results
-
$qry="select * from product_table where dealer_id=$dealer_id limit $offset,$limit";
-
$result=mysql_query($qry);
-
-
// now you can display the results returned
-
while ($row=mysql_fetch_array($result))
-
{
-
$desc = substr($row['detail_description'], 0, 250);
-
echo "<tr>";
-
echo "<td width=115 valign=top class=bord align=center>" ."<img width=92 border=0 height=115 src='http://localhost/vineet/graphics/" . $row['image'] . "'/>" . "</td>";
-
echo "<td valign=top width=150>". $row['product_name'] ."<br><br><br>". "Cutout Price"."<br>"."<span class='cut'>".$row['cutout_price']."</span>"."<br><br>". "Price"."<br>"."<span class='price16'>"."NZ$ ".$row['price']."</span>"."</td>";
-
echo "<td valign=top class='des' width=250>". $desc . "</td>";
-
echo "</tr>";
-
echo "<tr>";
-
echo "<td valign=top colspan=3 align=right>". "<img src='http://localhost/vineet/images/view_details.gif' border=0 />" . "</td>";
-
echo "</tr>";
-
echo "<tr>";
-
echo "<td class=shadow colspan=5>" . "<image src='http://localhost/vineet/images/spacer.gif' height=15 width=15>" . "</td>";
-
echo "</tr>";
-
}
-
-
// next we need to do the links to other results
-
-
if ($offset==0) { // bypass PREV link if offset is 0
-
$prevoffset=$offset-1;
-
print "<a href=\"products-10-1.html?offset=$prevoffset\">PREV</a> \n";
-
}
-
-
// calculate number of pages needing links
-
$pages=intval($numrows/$limit);
-
-
// $pages now contains int of pages needed unless there is a remainder from division
-
if ($numrows%$limit) {
-
// has remainder so add one page
-
$pages++;
-
}
-
-
for ($i=1;$i<=$pages;$i++) { // loop thru
-
$newoffset=$limit*($i-1);
-
print "<a href=\"products-10-1.html?offset=$newoffset\">$i</a> \n";
-
}
-
-
// check to see if last page
-
if (!(($offset/$limit)==$pages) && $pages!=1) {
-
// not last page so give NEXT link
-
$newoffset=$offset+$limit;
-
print "<a href=\"products-10-1.html?offset=$newoffset\">NEXT</a><p>\n";
-
}
-
?>
-
vineet
1 1148 nathj 938
Recognized Expert Contributor
Hi vineet,
I notice your SQL query is working on the dealer ID as stored in the $_RQUEST[] array, as an aside it's better to be specific, use $_GET for variables in the query string and $_POST for submitted variables.
I recommend echoing the SQL statement so you can see what the SQL is when you first visit the page and what it is when you click next. This should give you some clue as to what is happening with the SQL.
Cheers
nathj
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Kurzman |
last post by:
Let me know what you think about the following code:
DECLARE @MaxIdValue int
DECLARE @MaxSortFieldValue nvarchar(50)
SELECT TOP 1 @MaxIdValue = , @MaxSortFieldValue =
FROM (
SELECT TOP PageNumber*RowsPerPage ,
FROM MyTable
WHERE (FilterCondition) ORDER BY ,
) T
|
by: Chris H |
last post by:
I am having a problem with pagination, basically the problem is happening in
the "PREV / NUMBERS / NEXT" links, it appears as if the reason is becasue
the increment and decrement operators aren't functioning or the $page
variable isnt working in that part of the code... Below is the link to the
working but broken page.. as well as the main part of my code... Hopefully
someone can explain why the operators arent working or maybe see what i...
|
by: ste |
last post by:
Hi there,
Further to my recent posts where I've received excellent help from Rik and
Jerry, I've ended up with an image gallery on my website that displays
images in a table, 3 images per row. This works great and opens all images
in the database when I open the url mywebsite/gallery.php, or I can choose
certain images (by category) by going to url's like
mywebsite/gallery.php?category=landscape
Although the above worked perfectly...
|
by: Sheau Wei |
last post by:
I am using php version 4.3.3.
The below was my pagination code.
My problem is that when i run this code in my computer, i wall fail because of the hyperlink of the pagination not function when i click it. But when i run in other people computer, It was no problem at all. I wonder to know what wrong to my coding . Is it different version of php also reflect the output?
<?
//required file for database connection
require("config.php");...
|
by: s4lin |
last post by:
problem is pagination not retaining data field
i have form with general data field, and i need to select some option which is store in database, so i open another page with retrieving data from table with pagination
form data's are retaining if i select from first page but data not retaining if i select option from other than 1st page. i m using hidden field in pagination page.
Thanks
stalin
| |
by: shalini jain |
last post by:
Hi, I want to know how can we do pagination using XSL. There are number of tutorials available on pagination using PHP but nothing with XSL. i am really stuck with my code.
Below is the code that i have written for pagination but it displays the link of all the pages at one go i.e. if i have 8 pages showing 10 results per page than it shows links for all 8 pages.
Previous 1-10 11-20 21-30 31-40 41-50 51-60 61-70 71-80 Next
i want to...
|
by: gnawz |
last post by:
I have a pagination function I am using in a file called functions.php as below<? //Pagination functions function getPagingQuery($sql, $itemPerPage = 10) { if (isset($_GET) && (int)$_GET > 0) { $page = (int)$_GET; } else { $page = 1; } // start fetching from this row number $offset = ($page - 1) * $itemPerPage; return $sql . " LIMIT $offset, $itemPerPage"; } /* Get the links to navigate between...
|
by: markrawlingson |
last post by:
Hello,
For starters:
Yes, I am new to asp.net, however I hold a good 9-10 years of experience working with classic asp and am only just now upgrading my skills. I'm picking asp.net up pretty quickly but I'm running into a stumbling block that I just can't seem to get around. I think I know what the problem is, and I'm pretty confident in a work around, but it's not quite what I had hoped for so I thought I'd pick some of the experts brains...
|
by: ArizonaJohn |
last post by:
Hello,
The code below works great. The user enters a name into an HTML form, the code looks up a table with that name, and then that table is displayed.
I am trying to use pagination with it, and the pagination almost works. The first page of the pagination works fine, but when I click on one of the links for one of the next pages, the page is blank.
I have seen people mention this problem, and they have been told that a variable is...
|
by: kkshansid |
last post by:
this is my search page on which i am getting two parameters from previous page but the problem is that as soon as i click any other next pages my sql query fails as it doesnt get these two parameters
kindly help
<?php
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |