473,395 Members | 1,535 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,395 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 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 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:

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. ?>
  78.  
  79.  
Dec 23 '13 #1
0 1152

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() {...
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-> ";
0
by: ROXIT | last post by:
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...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
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,...
0
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...
0
jinu1996
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.