【发布时间】:2013-05-26 12:29:59
【问题描述】:
我正在使用 PHP 以显示的布局输出一周中每天 3-4 个员工轮班持续时间的时间表日历类型显示:
|=========|==========================================================|
| | | STEVE | |
| |==========================================================|
| $DATE | | SARAH | |
| |==========================================================|
| | | JODIE | |
|=========|==========================================================|
在使用 IMG SRC 时它可以正常工作,但是我需要在上面放置超链接文本。我现在似乎正在失去中间跨度的正确垂直尺寸,或者它跳到下一行。我试图通过所见或通过 CSS 的跨度样式更好地保护跨度边界,但无法弄清楚。我的方向正确吗?
另外...与移位行相比,$date 框的行高不同,使用更多的 div/span 而不是 TD/TR 来创建所需的输出会更好吗?
<?php
require'connect.php';
$query="SELECT mname,
((((TIME_TO_SEC(start) / '60') / '15') * '10') - '400'),
((((TIME_TO_SEC(finish) / '60') / '15') * '10') - (((TIME_TO_SEC(start) / '60') / '15') * '10')),
('960' - (((TIME_TO_SEC(finish) / '60') / '15') * '10'))
FROM schedule WHERE date >= NOW() AND date <= NOW() + INTERVAL 14 DAY ORDER BY date asc";
$result=mysql_query($query);
$num=mysql_numrows($result);
$a=0;
echo"<div><center><IMG SRC='images/filler1.jpg' WIDTH=80 HEIGHT=40></TD><IMG SRC='images/filler1.jpg' WIDTH=560 HEIGHT=40></center></div>";
echo"<div><center><TABLE WIDTH=640 BORDER=0 CELLPADDING=0 CELLSPACING=0>";
while ($a < $num){
$mname=mysql_result($result,$a,"mname");
$width1=mysql_result($result,$a,"((((TIME_TO_SEC(start) / '60') / '15') * '10') - '400')");
$width2=mysql_result($result,$a,"((((TIME_TO_SEC(finish) / '60') / '15') * '10') - (((TIME_TO_SEC(start) / '60') / '15') * '10'))");
$width3=mysql_result($result,$a,"('960' - (((TIME_TO_SEC(finish) / '60') / '15') * '10'))");
$rowheight=("120" / $num);
if ($a < 1){echo"
<TR>
<TD><IMG SRC='images/Shift_06.jpg' WIDTH=80 HEIGHT=120></TD>
<TD>
<IMG SRC='images/filler1.jpg' width='$width1' height='$rowheight'>
<span style='display:inline-block; width:$width2; height:$rowheight; text-align:center; font-family: Annifont; font-size: 13px; background-color:#b0c4de; border:none;'><a href='$name.html'>$mname</a></span>
<IMG SRC='images/filler1.jpg' width='$width3' height='$rowheight'>";}
if ($a > 0){echo"<br>
<IMG SRC='images/filler1.jpg' width='$width1' height='$rwoheight'>
<span style='display:inline-block; width:$width2; height:$rowheight; text-align:center; font-family: Annifont; font-size: 13px; background-color:#b0c4de; border:none;'><a href='$name.html'>$mname</a></span>
<IMG SRC='images/filler1.jpg' width='$width3' height='$rowheight'>";}
$a++;}
echo"</TD></TR></TABLE></center></div>";
if (!mysql_query($query))
{die('Error: ' . mysql_error());}
mysql_close();
?>
【问题讨论】:
-
这看起来更像是一个 HTML/CSS 问题,所以最好显示一些渲染的 HTML 而不是 PHP。此外,如果您可以通过jsfiddle 显示您的确切问题,那就更好了。
-
到目前为止我还没有制作任何 HTML,只是在处理这个 PHP 输出。