yandoo Posted July 10, 2007 Share Posted July 10, 2007 Hi, Was hoping for some advice with a part of page navigation.... It works at the moment so there is a "Previous" & "Next" Hyperlink underneath the records. In between the Previous & Next links are the number of pages that there is of these records. e.g: Previous 1234 Next This is fine if there are only a few pages of records, but when there are hundreds of pages the numbers are listed and they take up half the web page with them. How can i make it so only limited 10 numbers of pages say appear between the "Previous" & "Next" Hyperlink and as you progress through the pages they are as do the next 10 numbers of pages??? Heres my pagnation code: if ($page > 1) echo '<a href="?search=Search&finda='.$find.'&field='.$field.'&page='.($page - 1).'"> PREV </a>'; else echo ' PREV '; echo "</td> \n"; echo "<td>"; for ($i =1; $i <= $tot_pages; $i++) { if ($i != $page) echo '<a href="?search=Search&finda='.$find.'&field='.$field.'&page='.$i.'"> '.$i.' </a>'; else echo " $i "; } echo "</td> \n"; echo "<td>"; if ($page < $tot_pages) echo '<a href="?search=Search&finda='.$find.'&field='.$field.'&page='.($page + 1).'"> NEXT </a>'; else echo ' NEXT '; echo "</td> \n"; echo "<td>"; echo "</td> \n"; echo "</table> \n"; } else die('error'); I hope this makes sense. Thank You Quote Link to comment Share on other sites More sharing options...
OLG Posted July 10, 2007 Share Posted July 10, 2007 I should imagine something like this would do the trick, although i haven't tested it if ($page > 1) echo '<a href="?search=Search&finda='.$find.'&field='.$field.'&page='.($page - 1).'"> PREV </a>'; else echo ' PREV '; echo "</td> \n"; echo "<td>"; for ($i =1; $i <= $tot_pages; $i++) { if ($i != $page) echo '<a href="?search=Search&finda='.$find.'&field='.$field.'&page='.$i.'"> '.$i.' </a>'; else echo " $i "; if($i == 10) break; } echo "</td> \n"; echo "<td>"; if ($page < $tot_pages) echo '<a href="?search=Search&finda='.$find.'&field='.$field.'&page='.($page + 1).'"> NEXT </a>'; else echo ' NEXT '; echo "</td> \n"; echo "<td>"; echo "</td> \n"; echo "</table> \n"; } else die('error'); Quote Link to comment Share on other sites More sharing options...
yandoo Posted July 10, 2007 Author Share Posted July 10, 2007 Hi, thanks for the reply, thats great it does limit the number to only 10. But when you get to the 10th record the number of pages is still diaplayed as 1 2 3 4 5 6 7 8 9 10...... How do i make it so that whatever record is being viewed that page number is in the middle of the limited 10 page numbers that are displayed?????? e.g: if viewing 10th record 5 6 7 8 9 10 11 12 13 14 15 if viewing 15th record 10 11 12 13 14 15 16 17 18 19 20 Any help greatly appreciated Thank You Quote Link to comment Share on other sites More sharing options...
per1os Posted July 10, 2007 Share Posted July 10, 2007 http://cms.227net.com/php/google_like_pagination http://code.google.com/p/phppaginator/ Plenty of examples... Quote Link to comment Share on other sites More sharing options...
Psycho Posted July 10, 2007 Share Posted July 10, 2007 It would be helpful if you stated what you want to happen when the page is near the beginning or the end of the page count. For example, for page 2 do you want a total of ten (additional) pages displayed (1 2 3 4 5 6 7 8 9 10 11) or do you only want 5 pages before and after (1 2 3 4 5 6) - excluding those out of range? Quote Link to comment Share on other sites More sharing options...
yandoo Posted July 10, 2007 Author Share Posted July 10, 2007 Hi, thanks for reply. Was hoping for it to be 5 on either side......but if it was on page 2 there could only be the standard 12345678910...as there is only 1 previous page. so ideally 5 on either side is it easily dooable?? thank you Quote Link to comment Share on other sites More sharing options...
Psycho Posted July 10, 2007 Share Posted July 10, 2007 Forget I asked. It's easier to show +/- 5 pages excluding those out of range: <?php //Display the PREV link echo "<td>"; if ($page > 1) { echo '<a href="?search=Search&finda='.$find.'&field='.$field.'&page='.($page - 1).'"> PREV </a>'; } else { echo ' PREV '; } echo "</td> \n"; //Set the starting and ending pages (+/-5 pages from the current page) $start_page = ($page-5<1)?1:($page-5); //Set starting page to page-5, or 1 if less than 1 $end_page = ($page+5>$tot_pages)?$tot_pages:($page+5); //Set ending page to page+5, or tot_pages if more than 1 //Display the page links echo "<td>"; for ($i=$start_page; $i<=$end_page; $i++) { if ($i != $page) { echo '<a href="?search=Search&finda='.$find.'&field='.$field.'&page='.$i.'"> '.$i.' </a>'; } else { else echo " $i "; } } echo "</td> \n"; //Display the NEXT link echo "<td>"; if ($page < $tot_pages) { echo '<a href="?search=Search&finda='.$find.'&field='.$field.'&page='.($page + 1).'"> NEXT </a>'; } else { echo ' NEXT '; } echo "</td> \n"; ?> Quote Link to comment Share on other sites More sharing options...
AdRock Posted July 10, 2007 Share Posted July 10, 2007 I found this ages ago but i can't remember where....it's like Google pagination You can style it with CSS There are 6 different functions to create the pagination <?php $webpage = basename(news); function pagination_one($total_pages,$page){ global $webpage; echo '<div class="page_numbers"> <ul>'; if($total_pages!=1){ for ($i=1;$i<$total_pages+1;$i++){ if($i==$page){ echo '<li><a class="current">'.$i.'</a></li> '; } else{ echo '<li><a href="'.$webpage.'?page='.$i.'">'.$i.'</a></li> '; } } echo '</ul> </div>'; } } function pagination_two($total_pages,$page){ global $webpage; echo '<div class="page_numbers"> <ul>'; if($page>"1"){ echo '<li class="current"><a href="'.$webpage.'?page=1">First</a></li> <li class="current"><a href="'.$webpage.'?page='.($page-1).'">Prev</a></li> '; } if($total_pages!=1){ for ($i=1;$i<$total_pages+1;$i++){ if($i==$page){ echo '<li><a class="current">'.$i.'</a></li> '; } else{ echo '<li><a href="'.$webpage.'?page='.$i.'">'.$i.'</a></li> </li>'; } } } if(($page >="1")&&($page!=$total_pages)){ echo '<li class="current"><a href="'.$webpage.'?page='.($page+1).'">Next</a></li> <li class="current"><a href="'.$webpage.'?page='.$total_pages.'">Last</a></li> '; } echo '</ul> </div>'; } function pagination_three($total_pages,$page){ global $webpage; echo '<div class="page_numbers"> <ul>'; if($page>"1"){ echo '<li class="current"><a href="'.$webpage.'?page=1">First</a></li> <li class="current"><a href="'.$webpage.'?page='.($page-1).'">Prev</a></li> '; } if($total_pages!=1){ $maximum_links = 10; if($page>=$maximum_links){ $maximum_links=$page; } for ($i=1;$i<$maximum_links+1;$i++){ if($i==$page){ echo '<li><a class="current">'.$i.'</a></li> '; } else{ echo '<li><a href="'.$webpage.'?page='.$i.'">'.$i.'</a></li> '; } } } if(($page >="1")&&($page!=$total_pages)){ echo '<li class="current"><a href="'.$webpage.'?page='.($page+1).'">Next</a></li> <li class="current"><a href="'.$webpage.'?page='.$total_pages.'">Last</a></li> '; } echo '</ul> </div>'; } function pagination_four($total_pages,$page){ global $webpage; $max_links = 11; $max = 6; $shift = 5; $h=1; if($total_pages>$max_links){ if(($page>=$max_links-$shift)&&($page<=$total_pages-$shift)){ $max_links = $page+$shift; $h=$max_links-$max; } if($page>=$total_pages-$shift+1){ $max_links = $total_pages+1; $h=$max_links-$max; } } else{ $h=1; $max_links = $total_pages+1; } echo '<div class="page_numbers"> <ul>'; if($page>"1"){ echo '<li class="current"><a href="'.$webpage.'?page=1">First</a></li> <li class="current"><a href="'.$webpage.'?page='.($page-1).'">Prev</a></li> '; } if($total_pages!=1){ for ($i=$h;$i<$max_links;$i++){ if($i==$page){ echo '<li><a class="current">'.$i.'</a></li> '; } else{ echo '<li><a href="'.$webpage.'?page='.$i.'">'.$i.'</a></li> '; } } } if(($page >="1")&&($page!=$total_pages)){ echo '<li class="current"><a href="'.$webpage.'?page='.($page+1).'">Next</a></li> <li class="current"><a href="'.$webpage.'?page='.$total_pages.'">Last</a></li> '; } echo '</ul> </div>'; } function pagination_five($total_pages,$page){ global $webpage; $max_links = 10; $h=1; if($page>$max_links){ $h=(($h+$page)-$max_links); } if($page>=1){ $max_links = $max_links+($page-1); } if($max_links>$total_pages){ $max_links=$total_pages+1; } echo '<div class="page_numbers"> <ul>'; if($page>"1"){ echo '<li class="current"><a href="/'.$webpage.'/1">First</a></li> <li class="current"><a href="/'.$webpage.'/'.($page-1).'">Prev</a></li> '; } if($total_pages!=1){ for ($i=$h;$i<$max_links;$i++){ if($i==$page){ echo '<li><a class="current">'.$i.'</a></li>'; } else{ echo '<li><a href="/'.$webpage.'/'.$i.'">'.$i.'</a> </li>'; } } } if(($page >="1")&&($page!=$total_pages)){ echo '<li class="current"><a href="/'.$webpage.'/'.($page+1).'">Next</a></li> <li class="current"><a href="/'.$webpage.'/'.$total_pages.'">Last</a></li> '; } echo '</ul> </div> '; } function pagination_six($total_pages,$page){ global $webpage; $max_links=10; $max_links_marker = $max_links+1; $h=1; $link_block=(($page-1)/$max_links); if(($page>=$max_links_marker)&&(is_int($link_block))){ $max_links_marker=$page+$max_links; $h=$max_links_marker-$max_links; $prev=$h-1; } elseif(($page>=$max_links_marker)&&(!is_int($link_block))){ $round_up=ceil($link_block); $new_top_link = $round_up*$max_links; $max_links_marker=$new_top_link+1; $h=$max_links_marker-$max_links; $prev=$h-1; } if($max_links_marker>$total_pages){ $max_links_marker=$total_pages+1; } echo '<div class="page_numbers"> <ul>'; if($page>"1"){ echo '<li class="current"><a href="'.$webpage.'?page=1">First</a></li> <li class="current"><a href="'.$webpage.'?page='.($page-1).'">Prev</a></li>'; } $prev_start = $h-$max_links; $prev_end = $h-1; if($prev_start <=1){ $prev_start=1; } $prev_block = "Pages $prev_start to $prev_end"; if($page>$max_links){ echo '<li class="current"><a href="'.$webpage.'?page='.$prev.'">'.$prev_block.'</a></li>'; } if($total_pages!=1){ for ($i=$h;$i<$max_links_marker;$i++){ if($i==$page){ echo '<li><a class="current">'.$i.'</a></li>'; } else{ echo '<li><a href="'.$webpage.'?page='.$i.'">'.$i.'</a></li>'; } } } else{ echo '<li><a class="current">'.$page.'</a>'; } $next_start = $max_links_marker; $next_end = $max_links_marker+$max_links; if($next_end >=$total_pages){ $next_end=$total_pages; } $next_block = "Pages $next_start to $next_end"; if($total_pages>$max_links_marker-1){ echo '<li class="current"><a href="'.$webpage.'?page='.$max_links_marker.'">'.$next_block.'</a></li>'; } if(($page >="1")&&($page!=$total_pages)){ echo '<li class="current"><a href="'.$webpage.'?page='.($page+1).'">Next</a></li> <li class="current"><a href="'.$webpage.'?page='.$total_pages.'">Last</a></li>'; } echo '</ul> </div>'; } ?> Here is what I used if you want to filter the crap you don't need (i'm too lazy to do that) <h2>General Articles</h2><hr /> <div> <?php include "includes/connection.php"; $webpage = basename(articles); function pagination_five($total_pages,$page){ global $webpage; $max_links = 10; $h=1; if($page>$max_links){ $h=(($h+$page)-$max_links); } if($page>=1){ $max_links = $max_links+($page-1); } if($max_links>$total_pages){ $max_links=$total_pages+1; } echo '<div class="page_numbers"> <ul>'; if($page>"1"){ echo '<li class="current"><a href="/'.$webpage.'/1">First</a></li> <li class="current"><a href="/'.$webpage.'/'.($page-1).'">Prev</a></li> '; } if($total_pages!=1){ for ($i=$h;$i<$max_links;$i++){ if($i==$page){ echo '<li><a class="current">'.$i.'</a></li>'; } else{ echo '<li><a href="/'.$webpage.'/'.$i.'">'.$i.'</a> </li>'; } } } if(($page >="1")&&($page!=$total_pages)){ echo '<li class="current"><a href="/'.$webpage.'/'.($page+1).'">Next</a></li> <li class="current"><a href="/'.$webpage.'/'.$total_pages.'">Last</a></li> '; } echo '</ul> </div> '; } $result = mysql_query("Select count(*) from articles WHERE archived='n'") or die (mysql_error()); $numrows = mysql_fetch_row($result); if(isset($_GET['pagenum'])?$page = $_GET['pagenum']:$page = 1); $entries_per_page = 1; $total_pages = ceil($numrows[0]/$entries_per_page); $offset = (($page * $entries_per_page) - $entries_per_page); //after we have $total_pages and $page, we can include the //pagination style wherever we want on the page. //so far there is no output from the script, so we could have //pagination before or after the pages results //before the results $result = mysql_query("SELECT id,title,content, DATE_FORMAT(time, '%W %D %M %Y') as date, photo FROM articles WHERE archived='n' ORDER BY id DESC LIMIT $offset,$entries_per_page"); if(!$result) die(mysql_error()); $err = mysql_num_rows($result); if($err == 0) die("No matches met your criteria."); while($row=mysql_fetch_array($result)){ $title = htmlentities(strtoupper($row['title'])); $content = htmlentities($row['content']); if (!$row['photo']){ echo "<div id='right'><h3>".$title."</h3><p style='text-align:left'><i>Date added: ".$row['date']."</i></p><p>".nl2br($content)."</p><br /></div>\n"; } else { echo "<div id='right'><h3>".$title."</h3><p style='text-align:left'><i>Date added: ".$row['date']."</i></p><p><img src='/images/large/".$row['photo']."' alt='".$row['alternate']."' class='right' />".nl2br($content)."</p><br /></div>\n"; } } //or after the results pagination_five($total_pages,$page); ?> </div> Quote Link to comment Share on other sites More sharing options...
OLG Posted July 10, 2007 Share Posted July 10, 2007 Well, here is some bull i just threw together - i'm sure its not as impressive as other's, but it gets the job done and is simple, take it or leave it. <?php if($page <= 0) { die("Negative page or 0 page, thats hilarious! Have you never read a book you idiot?"); } if($page <= 5) { $amount = 10; if($page == 1) { echo ' PREV '; echo "</td> \n"; echo "<td>"; } else { echo '<a href="?search=Search&finda='.$find.'&field='.$field.'&page='.($page - 1).'"> PREV </a>'; } $next = (10 - $page); $over = ($next + 1); for ($i = 1; $i <= $next; $i++) { if ($i != $page) { echo '<a href="?search=Search&finda='.$find.'&field='.$field.'&page='.$i.'"> '.$i.' </a>,'; } else { echo $i; } } for ($i = $over; $i <= 10; $i++) { echo '<a href="?search=Search&finda='.$find.'&field='.$field.'&page='.$i.'"> '.$i.' </a>,'; } echo '<a href="?search=Search&finda='.$find.'&field='.$field.'&page='.($page + 1).'"> NEXT </a>'; } elseif ($page > 5) { $diff = ($page - 5); $additional = ($page + 5); $over = ($page + 1); echo '<a href="?search=Search&finda='.$find.'&field='.$field.'&page='.($page - 1).'"> PREV </a>,'; for ($i = $diff ; $i <= $page; $i++) { if ($i != $page) { echo '<a href="?search=Search&finda='.$find.'&field='.$field.'&page='.$i.'"> '.$i.' </a>,'; } else { echo $i; } } $check = $over + 5; if ($check >= $tot_pages) { $additional = $tot_pages; } for ($i = $over ; $i <= $additional; $i++) { if ($i != $page) { echo '<a href="?search=Search&finda='.$find.'&field='.$field.'&page='.$i.'"> '.$i.' </a>,'; } } if($page < $tot_pages) { echo '<a href="?search=Search&finda='.$find.'&field='.$field.'&page='.($page + 1).'"> NEXT </a>'; } else { echo ' NEXT '; } echo "</td> \n"; echo "<td>"; echo "</td> \n"; echo "</table> \n"; } ?> This will give you , 1,2,3,4,5,6,7,8,9,10 if your under <5 and -/+ 5 either side if your above. Not sure why your using \n instead of <br> but i left it there. Quote Link to comment Share on other sites More sharing options...
AdRock Posted July 10, 2007 Share Posted July 10, 2007 Here is the CSS i have for my pagination......you can see it in action at http:www.jackgodfrey.org.uk .page_numbers { width: 600px; padding: 5px 0px; float:left; clear:left; margin:0 auto; } .page_numbers ul { margin: 0 auto; list-style-type: none; padding: 0px; text-align: center; } .page_numbers li { display: inline; float: left; margin:1px; background: #a7a7a7; width:25px; } .page_numbers li.current{ width:50px; } .page_numbers li a { background: #fff; border: 1px solid #a7a7a7; padding: 1px; text-decoration: none; color: #000; font:bold 8px verdana,sans-serif; display:block; } .page_numbers a.current, .page_numbers li a:hover { background: #a7a7a7; color: #fff; } Quote Link to comment Share on other sites More sharing options...
yandoo Posted July 11, 2007 Author Share Posted July 11, 2007 Hi there, thank you all for replies, theres loads of cool stuff i can work with here!! So far im going through it systematically and im trying the code from mjdamato. I seem to be having a bit of trouble with it. I keep getting this error: Parse error: syntax error, unexpected T_ELSE in C:\wamp\www\local_sites\LaptopLoanDatabase\search_loan_details.php on line 336 That line points to this line of code: else echo " $i "; Im a little confused now. I think i should point out that the records that from the pages that i am adding page navigation too, are the results of a search!! Below is the full page of code that i am using...I hope this explains better than i am... <?php $limit = 2; $fields = array("LoanID", "Client", "StudentName", "LaptopName", "Date", "Username", "Complete", "Description"); if (isset($_GET['search']) and $_GET['search'] == 'Search'){ $page = trim(addslashes(strip_tags($_GET['page']))); if($page == "" OR !is_numeric($page)) $page = 1; $find = strtoupper($_GET['finda']); $find = strip_tags($_GET['finda']); $find = trim ($_GET['finda']); $find = mysql_real_escape_string($find); if (in_array($_GET['field'], $fields)) $field = $_GET['field']; else die('wrong field name'); if ($find) $where = ' WHERE '.$field." LIKE '%".$find."%'"; else $where = ' WHERE 1'; $lm = ' LIMIT '.(($page - 1) * $limit).', '.$limit; $qve_tot_row = "SELECT count(*) FROM loan".$where; $qve_data = "SELECT * FROM loan".$where.$lm; echo '<br/>'; $res = mysql_query($qve_tot_row); $tot_row = mysql_result($res, 0, 0); $tot_pages = ceil($tot_row / $limit); $res =mysql_query($qve_data) or die(mysql_error()); if (mysql_num_rows($res) > 0) { while($result = mysql_fetch_array($res)) { echo"<table width=\"200\" border=\"0\" class=\"border_bottom\"> \n"; echo "<tr> \n"; echo "<td> </td> \n"; echo "</td> \n"; echo "</tr> \n"; echo "<tr> \n"; echo "<td>"; echo "<strong>Loan ID</strong>"; echo "</td>"; echo "<td width=\"75\" style =\"text-align: left\""; ?> <em><a href="search_loan_details.php?recordID=<?php echo $result['LoanID']; ?>"><?php echo $result['LoanID']; ?> </a></em> <?php echo " </td> \n"; echo "</tr> \n"; echo "<tr> \n"; echo "<td>"; echo "<strong>Client Name</strong>"; echo "</td>"; echo "<td>"; echo "<em>"; echo $result['Client']; echo "</em>"; echo "</td>"; echo "</tr> \n"; echo "<tr> \n"; echo "<td>"; echo "<strong>Student Name </strong>"; echo "</td>"; echo "<td>"; echo "<em>"; echo $result['StudentName']; echo "</em>"; echo "</td>"; echo "</tr> \n"; echo "<tr> \n"; echo "<td>"; echo "<strong>Laptop Name</strong>"; echo "</td>"; echo "<td>"; echo "<em>"; echo $result['LaptopName']; echo "</em>"; echo "</td>"; echo "</tr> \n"; echo "<tr> \n"; echo "<td>"; echo "<strong>Username</strong>"; echo "</td>"; echo "<td>"; echo "<em>"; echo $result['Username']; echo "</em>"; echo "</td>"; echo "</tr> \n"; echo "<tr> \n"; echo "<td>"; echo "<strong>Date</strong>"; echo "</td>"; echo "<td>"; echo "<em>"; echo $result['Date']; echo "</em>"; echo "</td>"; echo "</tr> \n"; echo "<tr> \n"; echo "<td>"; echo "<strong>Complete</strong>"; echo "</td>"; echo "<td>"; echo "<em>"; echo $result['Complete']; echo "</em>"; echo "</td>"; echo "</tr> \n"; echo "<tr> \n"; echo "<td>"; echo "<strong>Description</strong>"; echo "</td>"; echo "<td>"; echo "<em>"; echo $result['Description']; echo "</em>"; echo "</td>"; echo "</tr> \n"; echo "<tr> \n"; echo "<td> </td> \n"; echo "</td> \n"; echo "</tr> \n"; echo "</table> \n"; echo"<br>"; } } else echo 'no result'; echo "<br>"; echo"<table width=\"200\" align=\"left\" border=\"0\"> \n"; echo "<tr> \n"; echo "<td>"; echo "</td> \n"; echo "<td>"; if ($page > 1) echo '<a href="?search=Search&finda='.$find.'&field='.$field.'&page='.($page - 1).'"> PREV </a>'; else echo ' PREV '; echo "</td> \n"; echo "<td>"; //echo $tot_pages; - test to display total pages for ($i =1; $i <= $tot_pages; $i++) { if ($i != $page) echo '<a href="?search=Search&finda='.$find.'&field='.$field.'&page='.$i.'"> '.$i.' </a>'; else echo " $i "; if($i == 10) break; } echo "</td> \n"; echo "<td>"; if ($page < $tot_pages) echo '<a href="?search=Search&finda='.$find.'&field='.$field.'&page='.($page + 1).'"> NEXT </a>'; else echo ' NEXT '; echo "</td> \n"; echo "<td>"; echo "</td> \n"; echo "</table> \n"; } else die('error'); ?> Please not this is my page navigation code.....When i get the error message im using: <?php $limit = 2; $fields = array("LoanID", "Client", "StudentName", "LaptopName", "Date", "Username", "Complete", "Description"); if (isset($_GET['search']) and $_GET['search'] == 'Search'){ $page = trim(addslashes(strip_tags($_GET['page']))); if($page == "" OR !is_numeric($page)) $page = 1; $find = strtoupper($_GET['finda']); $find = strip_tags($_GET['finda']); $find = trim ($_GET['finda']); $find = mysql_real_escape_string($find); if (in_array($_GET['field'], $fields)) $field = $_GET['field']; else die('wrong field name'); if ($find) $where = ' WHERE '.$field." LIKE '%".$find."%'"; else $where = ' WHERE 1'; $lm = ' LIMIT '.(($page - 1) * $limit).', '.$limit; $qve_tot_row = "SELECT count(*) FROM loan".$where; $qve_data = "SELECT * FROM loan".$where.$lm; echo '<br/>'; $res = mysql_query($qve_tot_row); $tot_row = mysql_result($res, 0, 0); $tot_pages = ceil($tot_row / $limit); $res =mysql_query($qve_data) or die(mysql_error()); if (mysql_num_rows($res) > 0) { while($result = mysql_fetch_array($res)) { echo"<table width=\"200\" border=\"0\" class=\"border_bottom\"> \n"; echo "<tr> \n"; echo "<td> </td> \n"; echo "</td> \n"; echo "</tr> \n"; echo "<tr> \n"; echo "<td>"; echo "<strong>Loan ID</strong>"; echo "</td>"; echo "<td width=\"75\" style =\"text-align: left\""; ?> <em><a href="search_loan_details.php?recordID=<?php echo $result['LoanID']; ?>"><?php echo $result['LoanID']; ?> </a></em> <?php echo " </td> \n"; echo "</tr> \n"; echo "<tr> \n"; echo "<td>"; echo "<strong>Client Name</strong>"; echo "</td>"; echo "<td>"; echo "<em>"; echo $result['Client']; echo "</em>"; echo "</td>"; echo "</tr> \n"; echo "<tr> \n"; echo "<td>"; echo "<strong>Student Name </strong>"; echo "</td>"; echo "<td>"; echo "<em>"; echo $result['StudentName']; echo "</em>"; echo "</td>"; echo "</tr> \n"; echo "<tr> \n"; echo "<td>"; echo "<strong>Laptop Name</strong>"; echo "</td>"; echo "<td>"; echo "<em>"; echo $result['LaptopName']; echo "</em>"; echo "</td>"; echo "</tr> \n"; echo "<tr> \n"; echo "<td>"; echo "<strong>Username</strong>"; echo "</td>"; echo "<td>"; echo "<em>"; echo $result['Username']; echo "</em>"; echo "</td>"; echo "</tr> \n"; echo "<tr> \n"; echo "<td>"; echo "<strong>Date</strong>"; echo "</td>"; echo "<td>"; echo "<em>"; echo $result['Date']; echo "</em>"; echo "</td>"; echo "</tr> \n"; echo "<tr> \n"; echo "<td>"; echo "<strong>Complete</strong>"; echo "</td>"; echo "<td>"; echo "<em>"; echo $result['Complete']; echo "</em>"; echo "</td>"; echo "</tr> \n"; echo "<tr> \n"; echo "<td>"; echo "<strong>Description</strong>"; echo "</td>"; echo "<td>"; echo "<em>"; echo $result['Description']; echo "</em>"; echo "</td>"; echo "</tr> \n"; echo "<tr> \n"; echo "<td> </td> \n"; echo "</td> \n"; echo "</tr> \n"; echo "</table> \n"; echo"<br>"; } } else echo 'no result'; echo "<br>"; echo"<table width=\"200\" align=\"left\" border=\"0\"> \n"; echo "<tr> \n"; echo "<td>"; echo "</td> \n"; echo "<td>"; //Display the PREV link echo "<td>"; if ($page > 1) { echo '<a href="?search=Search&finda='.$find.'&field='.$field.'&page='.($page - 1).'"> PREV </a>'; } else { echo ' PREV '; } echo "</td> \n"; //Set the starting and ending pages (+/-5 pages from the current page) $start_page = ($page-5<1)?1:($page-5); //Set starting page to page-5, or 1 if less than 1 $end_page = ($page+5>$tot_pages)?$tot_pages:($page+5); //Set ending page to page+5, or tot_pages if more than 1 //Display the page links echo "<td>"; for ($i=$start_page; $i<=$end_page; $i++) { if ($i != $page) { echo '<a href="?search=Search&finda='.$find.'&field='.$field.'&page='.$i.'"> '.$i.' </a>'; } else { else echo " $i "; } } echo "</td> \n"; //Display the NEXT link echo "<td>"; if ($page < $tot_pages) { echo '<a href="?search=Search&finda='.$find.'&field='.$field.'&page='.($page + 1).'"> NEXT </a>'; } else { echo ' NEXT '; } echo "</td> \n"; ?> If anyone can offer any assistance that be great. I'm fairly new to php but very eager. Thank You Quote Link to comment Share on other sites More sharing options...
OLG Posted July 11, 2007 Share Posted July 11, 2007 Post your other page here. Quote Link to comment Share on other sites More sharing options...
Psycho Posted July 11, 2007 Share Posted July 11, 2007 So far im going through it systematically and im trying the code from mjdamato. I seem to be having a bit of trouble with it. I keep getting this error: Parse error: syntax error, unexpected T_ELSE in C:\wamp\www\local_sites\LaptopLoanDatabase\search_loan_details.php on line 336 That line points to this line of code: else echo " $i "; Im a little confused now. I think i should point out that the records that from the pages that i am adding page navigation too, are the results of a search!! Below is the full page of code that i am using...I hope this explains better than i am... If you notice my sig it states "I do not always test the code I provide, so there may be some syntax errors." You just need to remove "else" from that line as it is already present on the line above it. There may be other syntax errors as well, but that one should have been pretty obvious. Quote Link to comment Share on other sites More sharing options...
OLG Posted July 11, 2007 Share Posted July 11, 2007 Ah, yes, how stupid of me not to spot that, I'll hold my head down in shame now. Quote Link to comment Share on other sites More sharing options...
yandoo Posted July 12, 2007 Author Share Posted July 12, 2007 Hey all, Thats Fantastic, thank you. I feel a bit silly really as i should have spotted it, even for an beginner. Thanks again Tom Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.