2012-07-22 126 views
0

我正在构建一个系统,您可以跟踪您的任务。 我现在来到一个问题,我希望把这张表的DIV导致溢出.....好吧,没有问题 - 除了它不溢出horizo​​nitly ...请有人可以帮我PHP表溢出

请有人可以帮我得到这适合....或帮我把这张桌子放在一张桌子上,以适应1100 x 545像素的区域..

我已经得到了一些好看的间距。 ..把它使溢出水平

$UArr = array("u1" => "Introduction to Marketing ", 
      "u2" => "Maintenance Unit ", 
      "u3" => "Starting a biz", 
      "u4" => "Web Design", 
      "u5" => "Webserver/PHP", 
      "u6" => "Modeling/Multimedia Design" , 
      "u7" => "CISCO 1 " , 
      "u8" => "CISCO 2 " , 
      "u9" => "C&G Marketing"); ///unit array 

$AArr = array("a1" => "Assignment 1", "a2" => "Assignment 2", "a3" => "Assignment 3", "a4" => "Assignment 4"); //assigment array 
$TArr = array("t1" => "Task 1", "t2" => "Task 2", "t3" => "Task 3", "t4" => "Task 4"); //task array 

$Connection = mysql_connect($host,$username, $password); 
mysql_select_db("dbname"); 

$Result = mysql_query("SELECT * FROM `tracker` WHERE `CollegeID`='collegeid' "); 
if(mysql_num_rows($Result) == 1) { 
    while($Data = mysql_fetch_array($Result)){ 
     $i = 0; 
     $Assignment = ""; 
     $Unit = ""; 
     $Task = ""; 
     echo "<table style=\"float:left;\" width=\"200\" border=\"0\" overflow:scroll;>"; 
     foreach($Data as $Item => $Value) { 
      if(!is_numeric($Item) && $Item !== "CollegeID") { 
       if($i == 0) { 
        $Unit = substr($Item, 0, 2); 
        $Assignment = substr($Item, 2, 2); 
        $Task = substr($Item, 4, 2); 
        echo "<tr style=\"text-align: center\"><td colspan=\"4\"><p>".$UArr[$Unit]."</p></td></tr>"; 
        echo "<tr style=\"text-align: center\"><td colspan=\"4\"><p>".$AArr[substr($Item, 2, 2)]."</p></td></tr>"; 
        echo "<tr><td width=\"10\">".$TArr[$Task]."</td><td width=\"10\">".DropDown($Item, $Value)."</td></tr>"; 
       } 
       if($Unit !== substr($Item, 0, 2)) { 
        echo "</tr>"; 
        echo "</tr>"; 
        echo "<table style=\"float:left;\" width=\"200\" border=\"0\">"; 
        $Unit = substr($Item, 0, 2); 
        echo "<tr style=\"text-align: center\"><td colspan=\"4\"><p>".$UArr[substr($Item, 0, 2)]."</p></td></tr>"; 
       } 
       if($Assignment !== substr($Item, 2, 2)) { 
        $Assignment = substr($Item, 2, 2); 
        echo "<tr style=\"text-align: center\"><td colspan=\"4\"><p>".$AArr[substr($Item, 2, 2)]."</p></td></tr>"; 
       } 
       if($Task !== substr($Item, 4, 2)) { 
        $Task = substr($Item, 4, 2); 
        echo "<tr><td width=\"10\">".$TArr[$Task]."</td><td width=\"50\">".DropDown($Item, $Value)."</td></tr>"; 
       } 
       $i++; 
      } 

     } 
     echo "</table>"; 

this is kinda how it looks, except the spacing is better and 4 units are overflowing

回答

0
Not an big issue with the scrolling. what i suggest to you that take a div and put a desired height width you want and apply the css as 

.divName 
{ 
height: //specify 
widht: //specify 
overflow:scroll; 
overflow-x:scroll; 
overflow-y:hidden; 
} 

,并把结果在这个div

+0

我已经将它包含在DIV的CSS中,并且为了调整大小,我增加了表格的宽度,并在单元标题上使用了大量'
'..现在看起来好吧 – Rsmithy 2012-07-23 12:41:16

+0

Thanx Rsmithy用于接受代码,我会感谢我今后继续努力。 – 2012-07-23 12:57:43

+0

即时代码解决方案发邮件给[email protected] – 2012-07-23 13:13:21

0

要使其水平溢出,只需将其放入另一个具有宽度(一个表格的宽度*您有多少表格)的精确值的<div>

在这个例子中使用9个表* 200像素= 1800px

我还建议使用表的宽度在风格或CSS类,如:

<table style="float:left;width:200px;border-width:0;overflow:scroll;"> 

您的代码是凌乱,需要被重新排列

+0

目前我已经取代用'

'在单元名称阵列上......我会看到在其他浏览器和解决方案中是什么样的......但我要称它为一个夜晚......我开始去盲目地编码.. 。谢谢你的帮助 – Rsmithy 2012-07-22 21:29:44