Expand|Select|Wrap|Line Numbers
- <?php
- include('dbconnect.php');
- $r="report";$m="memo";$me="meeting";$l="letter";$o="others";
- $s= $_POST['search'];
- $per_page = 3;
- if(isset($_POST['search']) && ($_POST['search'] != ""))
- {
- if($l)
- {
- $sql = ("SELECT subject,filename,bil FROM letter WHERE subject like '%$s%' OR filename LIKE '%$s%' ORDER BY subject ASC") or die ("Database Error!");
- $result = mysql_query($sql);
- while($row = mysql_fetch_array($result))
- {?><table border="0" cellpadding="5" >
- <tr>
- <td width=600><?php echo $row['subject'];?></td></font>
- <?php echo '<td width=400><font face=calibri> <a href="viewDocLetter.php?bil=' . $row['bil'] . '">'. $row['filename'].'</a> </td>';?>
- <td width=100><?php echo $l;?></td>
- </tr></table>
- <?php
- }
- $total = mysql_num_rows($result);
- }
- if($me)
- {
- $sql = ("SELECT subject,filename,bil FROM meeting WHERE subject like '%$s%' OR filename LIKE '%$s%' ORDER BY subject ASC") or die ("Database Error!");
- $result = mysql_query($sql);
- while($row = mysql_fetch_array($result))
- {?>
- <table border="0" cellpadding="5" >
- <tr>
- <td width=600><?php echo $row['subject'];?></td></font>
- <?php echo '<td width=400><font face=calibri> <a href="viewDocMeeting.php?bil=' . $row['bil'] . '">'. $row['filename'].'</a> </td>';?>
- <td width=100><?php echo $me;?></td>
- </tr></table>
- <?php
- }
- $totalmm = mysql_num_rows($result);
- }
- if($r)
- {
- $sql = ("SELECT subject,filename,bil FROM report WHERE subject like '%$s%' OR filename LIKE '%$s%' ORDER BY subject ASC") or die ("Database Error!");
- $result = mysql_query($sql);
- while($row = mysql_fetch_array($result))
- {?>
- <table border="0" cellpadding="5" >
- <tr>
- <td width=600><?php echo $row['subject'];?></td></font>
- <?php echo '<td width=400><font face=calibri> <a href="viewDocReport.php?bil=' . $row['bil'] . '">'. $row['filename'].'</a> </td>';?>
- <td width=100><?php echo $r;?></td>
- </tr></table>
- <?php
- }
- $totalr = mysql_num_rows($result);
- }
- if($m)
- {
- $sql = ("SELECT subject,filename,bil FROM memo WHERE subject like '%$s%' OR filename LIKE '%$s%' ORDER BY subject ASC") or die ("Database Error!");
- $result = mysql_query($sql);
- while($row = mysql_fetch_array($result))
- {?>
- <table border="0" cellpadding="5">
- <tr>
- <td width=600><?php echo $row['subject'];?></td></font>
- <?php echo '<td width=400><font face=calibri> <a href="viewDocMemo.php?bil=' . $row['bil'] . '">'. $row['filename'].'</a> </td>';?>
- <td width=100><?php echo $m;?></td>
- </tr></table>
- <?php
- }
- $totalm = mysql_num_rows($result);
- }
- if($o)
- {
- $sql = ("SELECT subject,filename,bil FROM others WHERE subject like '%$s%' OR filename LIKE '%$s%' ORDER BY subject ASC") or die ("Database Error!");
- $result = mysql_query($sql);
- while($row = mysql_fetch_array($result))
- {?>
- <table border="0" cellpadding="5" >
- <tr>
- <td width=600><?php echo $row['subject'];?></td></font>
- <?php echo '<td width=400><font face=calibri> <a href="viewDocOther.php?bil=' . $row['bil'] . '">'. $row['filename'].'</a> </td>';?>
- <td width=100><?php echo $o;?></td>
- </tr></table>
- <?php
- }
- $totalo = mysql_num_rows($result);
- }
- $totalresult=$totalo+$totalm+$totalmm+$totalr+$total;
- $tolpage=ceil($totalresult / $per_page);
- if (isset($_GET['page']) && is_numeric($_GET['page']))
- {
- $show_page = $_GET['page'];
- // make sure the $show_page value is valid
- if ($show_page > 0 && $show_page <= $tolpage)
- {
- $start = ($show_page -1) * $per_page;
- $end = $start + $per_page;
- }
- else
- {
- // error - show first set of results
- $start = 0;
- $end = $per_page;
- }
- }
- else
- {
- // if page isn't set, show first set of results
- $start = 0;
- $end = $per_page;
- }
- // display pagination
- echo "<p><font color=red>View Page: </font> ";
- for ($i = 1; $i <= $tolpage; $i++)
- {
- 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.
- }
- }
- else
- {?>
- <script type="text/Javascript">
- <!--
- window.alert("PLEASE ENTER KEYWORD TO SEARCH!");
- -->
- </script>
- <?php
- exit;
- }?>
- </body>
- </html>