473,406 Members | 2,439 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

use css to prevent tables spilling over page

170 100+
Hi

I have some tables generated from php code where there's a bunch of tables on a page. Each table could be a different height depending on user input. And there could be any number of tables.

I want to stop a table splitting into two and putting the last half on the next page when it's printed. Is there a way to do this using css?

I was thinking something like

*get the print area available somehow
* work out each table's table height
* keep adding the table heights until the total exceeds the available print height available
* tell it to print all tables on that page except the last one
* repeat the above for subsequent pages

I don't know if any of this is possible, or even if there's a much easier way.

Can anyone help this css newbie? In case it helps, the table-generating code is below

Expand|Select|Wrap|Line Numbers
  1. $i=0;
  2. while ($i < $num) 
  3.     {
  4.     $entry=mysql_result($result,$i,"entry");
  5.     $date=mysql_result($result,$i,"date");
  6.     $comps=mysql_result($result,$i,"comps");
  7.     $workplace=mysql_result($result,$i,"workplace");
  8.     $id=mysql_result($result,$i,"id");
  9.     $c=explode(',',$comps);
  10.     $count=count($c);
  11.  
  12.     echo "<br><table width=600><tr><td><b>Written on ".$date." &nbsp;  [Workplace: ".ucfirst($workplace)."]</b><br><ul>";
  13.  
  14.  
  15.     for($k=0; $k<mysql_num_fields($resultinfo); $k++)
  16.         {
  17.         $fieldname = mysql_fetch_field($resultinfo, $k);
  18.         $var=$fieldname->name;
  19.  
  20.         foreach($c as $values)
  21.             {
  22.             if(mysql_result($resultinfo,0,$var)==$values && $values!="")
  23.                 {
  24.                 echo "<li>".strtoupper($values)." (".mysql_result($resultinfo,0,str_replace('short','name',$var)).")</li>";
  25.                 }
  26.             }
  27.         }
  28.  
  29. echo "</ul>".nl2br($entry)."</td></tr></table>";
  30.  
  31.     $i++;
  32.     }
  33.  
May 9 '07 #1
0 1179

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Alpenvrouwtje | last post by:
Hallo, Does anyone have a (simple?) javascript code for me to prevent that people take the photo's of my website while they use the right mouse button. I know that there are ways around this...
3
by: Philip | last post by:
I am trying to replace extraneous tables with CSS but I am running into centering problems. I want pictures centered left to right (top aligned) in two columns, with the accompanying title and...
57
by: Bing Wu | last post by:
Hi all, I am running a database containing large datasets: frames: 20 thousand rows, coordinates: 170 million row. The database has been implemented with: IBM DB2 v8.1
3
by: Ken Varn | last post by:
I have an ASP.NET page that draws over 32 dynamic images using an HttpModule object through the <IMG> tag. Since IIS under Win2K Pro has a limit of 10 connections, some of the images do not get...
4
by: Rich | last post by:
I fill a dataset like this: dim da As New SqlDataAdapter, ds As New Dataset, conn As New SqlConnection .... da.Fill(ds, "tbl1") datagrid1.DataSource = ds datagrid1.DataMember = "tbl1" When...
18
by: Gleep | last post by:
I've searched google intensely on this topic and it seems noone really knows how to approch this. The goal I don't want clients to give out their usernames and passwords to friends, since the site...
59
by: phil-news-nospam | last post by:
In followups by Brian O'Connor (ironcorona) to other posts, he repeats the idea that using tables in CSS is not something that should be done because IE doesn't support it. Of course I'm not happy...
21
by: array7 | last post by:
I have been reading a lot of archived threads about "page-break- inside: avoid" not supported by IE5, IE6 IE55, IE7 and Firefox (Mozilla), which creates a really unpleasant-looking printout with...
2
by: beary | last post by:
Hi all, Problem: multiple tables of different heights (depending on amount of content) produced from database. Tables print down page and often break over the page. Number of tables and height of...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.