Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.