yandoo Posted May 18, 2007 Share Posted May 18, 2007 Hi, Ive created a recordset and the records are displayed logically down the page. Thing is I only want to display 10 records at a time to stop the page going on for ages as its filed with hundreds of records. In addition a need a: First, Last, Next & Previous hyperlinks that will enable the user to navigate these records. Heres my code for my page so far: <style type="text/css"> <!-- 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", "") 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 )) { ?> </span> <?php 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 "<br>"; echo "</table> \n"; echo "<br>"; echo"<table width=\"200\" border=\"0\" class=\"border_bottom\"> \n"; echo "<tr>"; echo "<td>"; echo "</td>"; echo "</tr>"; echo "</table>"; } //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); ?> The trouble is im not sure how to create the recordset navigation. If someone could either lend me some help or point me in right direction to get some help id be most greatful. Thank you [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/52005-recordset-navigation/ Share on other sites More sharing options...
hitman6003 Posted May 18, 2007 Share Posted May 18, 2007 You are wanting pagination... http://www.phpfreaks.com/tutorial_cat/25/Page-Number--Pagination.php Quote Link to comment https://forums.phpfreaks.com/topic/52005-recordset-navigation/#findComment-256337 Share on other sites More sharing options...
yandoo Posted May 18, 2007 Author Share Posted May 18, 2007 hi, Thanks for reply and info!! Thats marvelous ill be looking into this, this evening after work (sad i know). Thanks again tom Quote Link to comment https://forums.phpfreaks.com/topic/52005-recordset-navigation/#findComment-256344 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.