473,385 Members | 1,279 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Pagination script not working

10
Here i am collecting the category and area value from the search-form using get method.so as i m having a 7 records into the database and i want to display only 4 records per page and when user clicks on next button then the remaining records need to get displayed but here my code is displaying only first four records from the database but when i click on next button then the remaining 3 records are not getting displayed......

Consider area=Mumbai and category=lawn. and if there is only 7 records into the database then it i want first four to get display in first page and remaining 3 into the same page on clicking the next button..

Here is my code ....

please reply...

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.     $link=mysql_connect("localhost","root","");
  3.     mysql_select_db("celebration_db",$link);
  4.     $q="select count(*) \"total\"  from hallinfo";
  5.     $ros=mysql_query($q,$link);
  6.     $row=(mysql_fetch_array($ros));
  7.     $total=$row['total'];
  8.     $dis=4;
  9.     $total_page=ceil($total/$dis);
  10.     $page_cur=(isset($_GET['page']))?$_GET['page']:1;
  11.     $k=($page_cur-1)*$dis;
  12.  
  13.     $category = $_GET['category'];
  14.     $area = $_GET['area'];
  15.     //$category = 'hall';
  16.     //$area = 'nagpur';
  17.  
  18.     echo $category;
  19.     echo $area;
  20.  
  21.     $q="select * from hallinfo where category = '$category' AND area = '$area' limit $k,$dis";
  22.     //$q="select * from hallinfo limit $k,$dis";
  23.  
  24.     $ros=mysql_query($q,$link);
  25.     while($row=mysql_fetch_array($ros))
  26.     {
  27.         $imageId = $row['id'];
  28. echo '<div id="pattern">';    
  29. echo '<table>';
  30. echo '<tr>';
  31. echo '<td colspan="2" width="300px" height="200px">
  32.         <img src="image-show.php?id='.$imageId.'">';
  33. echo '</td>';
  34. echo '<td width="150px" height="200px">'.$row['description'];
  35. echo '</td>';
  36. echo '</tr>';
  37. echo '<tr>';
  38. echo '<td>'.$row['rent'];
  39. echo '</td>';
  40. echo '<td>'.$row['capacity'];
  41. echo '</td>';
  42. echo '<td>'.$row['area'];
  43. echo '</td>';
  44. echo '</tr>';
  45. echo '</table>';
  46. echo '</div>';
  47.     }
  48.     //echo '</table>';
  49.     //echo '<br/>';
  50.     if($page_cur>1)
  51.     {
  52.         echo '<a href="pagination.php?page='.($page_cur-1).'" style="cursor:pointer;color:green;" ><input style="cursor:pointer;background-color:green;border:1px black solid;border-radius:5px;width:120px;height:30px;color:white;font-size:15px;font-weight:bold;" type="button" value=" Previous "></a>';
  53.     }
  54.     else
  55.     {
  56.       echo '<input style="background-color:green;border:1px black solid;border-radius:5px;width:120px;height:30px;color:black;font-size:15px;font-weight:bold;" type="button" value=" Previous ">';
  57.     }
  58.     for($i=1;$i<$total_page;$i++)
  59.     {
  60.         if($page_cur==$i)
  61.         {
  62.             echo ' <input style="background-color:green;border:2px black solid;border-radius:5px;width:30px;height:30px;color:black;font-size:15px;font-weight:bold;" type="button" value="'.$i.'"> ';
  63.         }
  64.         else
  65.         {
  66.         echo '<a href="pagination.php?page='.$i.'"> <input style="cursor:pointer;background-color:green;border:1px black solid;border-radius:5px;width:30px;height:30px;color:white;font-size:15px;font-weight:bold;" type="button" value="'.$i.'"> </a>';
  67.         }
  68.     }
  69.     if($page_cur<$total_page)
  70.     {
  71.         echo '<a href="pagination.php?page='.($page_cur+1).'"><input style="cursor:pointer;background-color:green;border:1px black solid;border-radius:5px;width:90px;height:30px;color:white;font-size:15px;font-weight:bold;" type="button" value=" Next "></a>';
  72.     }
  73.     else
  74.     {
  75.      echo '<input style="background-color:green;border:1px black solid;border-radius:5px;width:90px;height:30px;color:black;font-size:15px;font-weight:bold;" type="button" value="   Next ">';
  76.     }
  77. ?>
Dec 11 '13 #1
0 1173

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: colossus73 | last post by:
Hi, since sf.net doesn't allow php script to write on the server even in a own web space they counsel to use mysql. On www.hotscripts.com I found some poll scripts using mysql but the...
4
by: sivapriyan | last post by:
Hello, My java script function is working well in IE but not in Firefox My javascript is function visible() {...
1
eragon
by: eragon | last post by:
i have a news archive on my website that is all compiled into 1 php pages and several inc pages containing the news article. When the page is first loaded, the div called "page1" is loaded, which...
4
by: itgaurav198 | last post by:
Hi, I have the following two problems. 1. The following script is Working in IE and not in Mozilla Firefox i.e. it si not setting the value of the textbox. <input type="text" name="notify">...
5
by: sandipon | last post by:
I have used the following Pagination script to display database records in a series of pages, but only the first page shows up properly, and on clicking the links of subsequent pages or the NEXT ,...
1
by: vinodkizhussery | last post by:
my javascript code is working in ie but not in mozila why ? how can i solve this problem. my code is attached...
18
by: tarunkhatri | last post by:
HI can anyone help me with a function of javascript ... that calculates the sum of all colums at the very last row and also sum of all rows at the very last coloum.... It wiuld be like a 2-d array...
4
by: Hotice | last post by:
I have a form for registering some bookings. The problem is that I want to validate the data users enter in this form. All works fine, excepting the booking hours (ready by and closing time). This...
2
by: Jim Burgess | last post by:
I am trying to get a portion of javascript to work in Firefox that works perfectly in I.E. In this first section of code, I have a drop down box that when the value is changed to 29 (Other), it...
2
by: madomokhtar | last post by:
#!/usr/bin/perl use HTTP::Request; use LWP::UserAgent; system('cls'); system "color 0a"; print"\n"; print " Please Enter IP\n Example: 192.168.1.1 or 192.168.1.1/path\n-> ";
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.