Jump to content

Display over multiple pages


cloudsurferuk

Recommended Posts

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>";

 

Link to comment
https://forums.phpfreaks.com/topic/187419-display-over-multiple-pages/
Share on other sites

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.

 

 

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

 

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 :D

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.