473,320 Members | 2,111 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,320 software developers and data experts.

pagination link does not working

ok,i'm in the middle to finish up my project for some org. , its regarding document management system. the problem here is that i want to use pagination in order to display the searching result of some keywords. which mean user will key in what they want to search in a form,and it will display the result and link for the next page, when pressed, the pagination link cant go to the next page cos it cant define what user key in. can some one please help??

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. include('dbconnect.php');
  3. $r="report";$m="memo";$me="meeting";$l="letter";$o="others";
  4. $s= $_POST['search'];
  5. $per_page = 3;
  6. if(isset($_POST['search']) && ($_POST['search'] != ""))
  7. {
  8.     if($l)
  9.     {
  10.         $sql = ("SELECT subject,filename,bil FROM letter WHERE subject like '%$s%' OR filename LIKE '%$s%' ORDER BY subject ASC") or die ("Database Error!");
  11.         $result = mysql_query($sql);
  12.  
  13.  
  14.  
  15.         while($row = mysql_fetch_array($result))
  16.         {?><table border="0" cellpadding="5" >
  17.             <tr>
  18.                 <td width=600><?php echo $row['subject'];?></td></font>
  19.                 <?php echo '<td width=400><font face=calibri> <a href="viewDocLetter.php?bil=' . $row['bil'] . '">'. $row['filename'].'</a> </td>';?>
  20.                 <td width=100><?php echo $l;?></td>
  21.            </tr></table>
  22.         <?php
  23.         }
  24.         $total = mysql_num_rows($result);
  25.  
  26.     }
  27.  
  28.      if($me)
  29.     {
  30.         $sql = ("SELECT subject,filename,bil FROM meeting WHERE subject like '%$s%' OR filename LIKE '%$s%' ORDER BY subject ASC") or die ("Database Error!");
  31.         $result = mysql_query($sql);
  32.  
  33.  
  34.         while($row = mysql_fetch_array($result))
  35.         {?>
  36.             <table border="0" cellpadding="5" >
  37.             <tr>
  38.                 <td width=600><?php echo $row['subject'];?></td></font>
  39.                 <?php echo '<td width=400><font face=calibri> <a href="viewDocMeeting.php?bil=' . $row['bil'] . '">'. $row['filename'].'</a> </td>';?>
  40.                 <td width=100><?php echo $me;?></td>
  41.             </tr></table>
  42.         <?php
  43.         }
  44.         $totalmm = mysql_num_rows($result);
  45.     }
  46.  
  47.      if($r)
  48.     {
  49.         $sql = ("SELECT subject,filename,bil FROM report WHERE subject like '%$s%' OR filename LIKE '%$s%' ORDER BY subject ASC") or die ("Database Error!");
  50.         $result = mysql_query($sql);
  51.  
  52.  
  53.         while($row = mysql_fetch_array($result))
  54.         {?>
  55.             <table border="0" cellpadding="5" >
  56.             <tr>
  57.                 <td width=600><?php echo $row['subject'];?></td></font>
  58.                 <?php echo '<td width=400><font face=calibri> <a href="viewDocReport.php?bil=' . $row['bil'] . '">'. $row['filename'].'</a> </td>';?>
  59.                 <td width=100><?php echo $r;?></td>
  60.             </tr></table>
  61.         <?php
  62.         }
  63.         $totalr = mysql_num_rows($result);
  64.     }
  65.  
  66.      if($m)
  67.     {
  68.         $sql = ("SELECT subject,filename,bil FROM memo WHERE subject like '%$s%' OR filename LIKE '%$s%' ORDER BY subject ASC") or die ("Database Error!");
  69.         $result = mysql_query($sql);
  70.  
  71.  
  72.         while($row = mysql_fetch_array($result))
  73.         {?>
  74.             <table border="0" cellpadding="5">
  75.             <tr>
  76.                 <td width=600><?php echo $row['subject'];?></td></font>
  77.                 <?php echo '<td width=400><font face=calibri> <a href="viewDocMemo.php?bil=' . $row['bil'] . '">'. $row['filename'].'</a> </td>';?>
  78.                 <td width=100><?php echo $m;?></td>
  79.             </tr></table>
  80.         <?php
  81.         }
  82.         $totalm = mysql_num_rows($result);
  83.     }
  84.  
  85.     if($o)
  86.     {
  87.         $sql = ("SELECT subject,filename,bil FROM others WHERE subject like '%$s%' OR filename LIKE '%$s%' ORDER BY subject ASC") or die ("Database Error!");
  88.         $result = mysql_query($sql);
  89.  
  90.  
  91.         while($row = mysql_fetch_array($result))
  92.         {?>
  93.             <table border="0" cellpadding="5" >
  94.             <tr>
  95.                 <td width=600><?php echo $row['subject'];?></td></font>
  96.                 <?php echo '<td width=400><font face=calibri> <a href="viewDocOther.php?bil=' . $row['bil'] . '">'. $row['filename'].'</a> </td>';?>
  97.                 <td width=100><?php echo $o;?></td>
  98.             </tr></table>
  99.         <?php
  100.         }
  101.         $totalo = mysql_num_rows($result);
  102.     }
  103.  
  104.         $totalresult=$totalo+$totalm+$totalmm+$totalr+$total;
  105.         $tolpage=ceil($totalresult / $per_page);
  106.  
  107.         if (isset($_GET['page']) && is_numeric($_GET['page']))
  108.         {
  109.                 $show_page = $_GET['page'];
  110.  
  111.                 // make sure the $show_page value is valid
  112.                 if ($show_page > 0 && $show_page <= $tolpage)
  113.                 {
  114.                         $start = ($show_page -1) * $per_page;
  115.                         $end = $start + $per_page; 
  116.                 }
  117.                 else
  118.                 {
  119.                         // error - show first set of results
  120.                         $start = 0;
  121.                         $end = $per_page; 
  122.                 }               
  123.         }
  124.         else
  125.         {
  126.                 // if page isn't set, show first set of results
  127.                 $start = 0;
  128.                 $end = $per_page; 
  129.         }
  130.  
  131.         // display pagination
  132.  
  133.  
  134.         echo "<p><font color=red>View Page: </font> ";
  135.         for ($i = 1; $i <= $tolpage; $i++)
  136.         {
  137.  
  138.                 echo "<a href='searching.php?page=$i'>$i</a> ";// i believe the problem should be here??i duno how can i decalre 'search' when it goes to another page.
  139.         }
  140. }
  141. else
  142. {?>
  143.     <script type="text/Javascript">
  144.     <!--
  145.     window.alert("PLEASE ENTER KEYWORD TO SEARCH!");
  146.  
  147.     -->
  148.     </script>
  149.     <?php
  150.     exit;
  151. }?>
  152.  
  153. </body>
  154. </html>
Attached Files
File Type: txt searching.txt (4.6 KB, 409 views)
Sep 12 '12 #1
0 1478

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

Similar topics

1
by: sihnstarr | last post by:
I have a pop-up window that contains a chart with a list of links. When the link is clicked, it is supposed to close the pop-up window and navigate to the page selected from the pop-up in the...
3
by: Quintus Snapper | last post by:
Hi All, I'm having a problem with an anchor link in IE which is working inconsistantly and I can't figure out why. On the following website: http://www.friendlyrentals.com/ If you click...
3
by: John Spiegel | last post by:
Hi all, I'm trying to do something simple here...just provide a link from which a user can download a file. I'm using Server.MapPath() in my codebehind to find out physically where the file is...
0
by: dermot | last post by:
Hi, I have an asp.net application called communityCarers It has a folder called download with a file called reporting.adp in it. I have a link on my site...
7
by: maaravi | last post by:
Hi, I'm trying to simulate clicking on a link, but Firefox seems to disable it. In the sample below, when clicking on the div tag, the onclick event of the link is triggered, but the browser...
3
by: Bruce A. Julseth | last post by:
The following link, in a PHP file, works fine in Firefox but "Nothing" happens when I click on the link in IE? Any idea why? <a href="addNewPatient.php" target="_blank"> <label>Add a new...
4
by: starman | last post by:
Hi - hopefully this is a simple question, just HTML / PHP. I have a php script that retrieves (among others) bare email addresses from a DB table (i.e., just in the form '...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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...

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.