cloudsurferuk Posted January 6, 2010 Share Posted January 6, 2010 Hi Guys, need some of your expert help again. I use the following code to display results from a database but often there are hundreds of results, how can I get this to display over multiple pages i.e. 50 results per page. (i know this seems basic but I am still basic with PHP) $result = mysql_query("SELECT * FROM routes WHERE Airline = '$carrier' AND DepID = '$hub' OR Airline = '$carrier' AND ArrID = '$hub' ORDER BY DepID, DepTime ASC"); // make box and name the fields in html echo "<table border='0' cellpadding='2' cellspacing='2'> <tr> <th>Flight Number</th> <th>Departure ICAO</th> <th>Block Off</th> <th>Arrival ICAO</th> <th>Block On</th> <th>Aircraft</th> <th>Info</th> <th>Average Duration</th> </tr>"; // fill box with data while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['FlightNo'] . "</td>"; echo "<td>" . $row['DepID'] . "</td>"; echo "<td>" . $row['DepTime'] . "</td>"; echo "<td>" . $row['ArrID'] . "</td>"; echo "<td>" . $row['ArrTime'] . "</td>"; echo "<td>" . $row['Equip'] . "</td>"; echo "<td>" . $row['Extra'] . "</td>"; echo "<td>" . $row['Avg_Dur'] . "</td>"; echo "</tr>"; } echo "</table>"; Quote Link to comment Share on other sites More sharing options...
incubi1 Posted January 6, 2010 Share Posted January 6, 2010 Hello, I'm sure there are better ways but, If you are looking for page breaks for printing then have a look here. http://www.javascriptkit.com/dhtmltutors/pagebreak.shtml The other way is in your loop count the number of lines displayed and then add a margin or blank spaces that will line the text up with a printout. Quote Link to comment Share on other sites More sharing options...
Psycho Posted January 6, 2010 Share Posted January 6, 2010 I think the OP is asking for help in paginating the results on screen for the user - not in the actual printing to hard copy. If so, there is a tutorial on this site just for that type of functionality: http://www.phpfreaks.com/tutorial/basic-pagination Quote Link to comment Share on other sites More sharing options...
cloudsurferuk Posted January 6, 2010 Author Share Posted January 6, 2010 I think the OP is asking for help in paginating the results on screen for the user - not in the actual printing to hard copy. If so, there is a tutorial on this site just for that type of functionality: http://www.phpfreaks.com/tutorial/basic-pagination Yup thats exactly what I wanted, thanks for pointing me to that 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.