yandoo Posted May 20, 2007 Share Posted May 20, 2007 Hi there, I have gone through the tutorial on php freaks for adding page navigation to records. I am in the middle of integrating the page navigation and have stuck on 2 areas. if anybody could help me out id be most greatful. Heres where im at.... 1) I have a page which displays a set of records (limited to 6 per page) Below,is the Next and Previous navigation text bUt it is not hyperlinked!!!?? The line of code specifically is: <?php echo("<a href=\"$PHP_SELF&page=$pageprev\">PREV".$limit."</a> "); - This should be hyper-linked but is not?? I think there could be a problem with the <href bit being AFTER the <?php. I am basing this on the fact that a previous record i made began the hyper-link <href BEFORE the <?php where as before the <?php was added only after : <a href="search_client_details.php?recordID=<?php echo $result['Client']; ?>"> 2) Other problem is only small as i'm trying to put the Previous and Next page navigation hyperlinks so they are side by side! I tried echoing new table but didnt show it at all. Please see screen shot of what page looks like and below is copy of code for it: <?php $limit = 6; $query_count = "SELECT count(*) FROM teachersname"; $result_count = mysql_query($query_count); $totalrows = mysql_num_rows($result_count); if(empty($page)){ $page = 1; } $limitvalue = $page * $limit - ($limit); $query = "SELECT * FROM teachersname WHERE " . $_POST['field'] . " LIKE '%$find%' LIMIT $limitvalue, $limit"; $result = mysql_query($query) or die("Error: " . mysql_error()); if(mysql_num_rows($result) == 0){ echo("Nothing to Display!"); } ?> body,td,th { font-family: Arial, Helvetica, sans-serif; font-size: 12px; } --> </style></head> <body> <span class="border_bottom"> <?php //check if the user entered data in the form if (isset($_POST['find'])) { //data has been entered so lets search the mofo echo "<h2>Results</h2><p>"; // sanitise the data $find = strtoupper($_POST['find']); $find = strip_tags($_POST['find']); $find = trim ($_POST['find']); //connect to the db //mysql_connect("localhost", "root", "winn3rs") or die(mysql_error()); //mysql_select_db("laptop_loan_database") or die(mysql_error()); //Now we search for our search term, in the field the user specified // $query = "SELECT * FROM teachersname WHERE " . $_POST['field'] . " LIKE '%$find%'" ; $data = mysql_query($query); //And we display the results while($result = mysql_fetch_array( $data )) { 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>Client Name</strong>"; echo "</td>"; echo "<td width=\"75\" style =\"text-align: left\""; ?> <em><a href="search_client_details.php?recordID=<?php echo $result['Client']; ?>"><?php echo $result['Client']; ?> </a></em> <?php echo " </td> \n"; echo "</tr> \n"; echo "<tr> \n"; echo "<td>"; echo "<strong>Department Code</strong>"; echo "</td>"; echo "<td>"; echo "<em>"; echo $result['DepartmentCode']; 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>"; } if($page != 1){ $pageprev = $page--; echo("<a href=\"$PHP_SELF&page=$pageprev\">PREV".$limit."</a> "); }else{ echo("PREV".$limit." "); } $numofpages = $totalrows / $limit; for($i = 1; $i <= $numofpages; $i++){ if($i == $page){ echo($i." "); }else{ echo("<a href=\"$PHP_SELF?page=$i\">$i</a> "); } } if(($totalrows % $limit) != 0){ if($i == $page){ echo($i." "); }else{ echo("<a href=\"$PHP_SELF?page=$i\">$i</a> "); echo "<br>"; } } if(($totalrows - ($limit * $page)) > 0){ $pagenext = $page++; echo("<a href=\"$PHP_SELF?page=$pagenext\">NEXT".$limit."</a>"); }else{ echo("NEXT".$limit); echo "\n"; } ?> </span> <?php } //This counts the number or results - and if there wasn't any it gives them a little message explaining that $anymatches=mysql_num_rows($data); if ($anymatches == 0) { echo "Sorry, but we can not find an entry to match your query<br><br>"; } ?> <?php mysql_free_result($user_conditional); ?> Any help would be so greatly appreciated!! Thanks [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/52222-adding-page-navigation-to-record-set/ 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.