php 多个table的格式问题
<?phpsession_start();echo"Hello!^_^".$_SESSION['first_name'];define('TITLE','Grade');...
<?phpsession_start();echo "Hello! ^_^ ".$_SESSION['first_name'];define('TITLE','Grade');$dbc= mysql_connect("localhost","root","") or die("error");mysql_select_db("project",$dbc);$id=$_SESSION['student_id'];$a=mysql_query("SELECT * FROM grade WHERE student_id ='$id'");while ($row=mysql_fetch_array($a)){ $n=(count($row)/2-1)/9; $row2=array_unique($row); $row3=count($row2); if($row3==1){ echo '<p>You do not have any grade until now.</p>'; } else{ $count=1; while($count<=$n){ $q1=($count-1)*9+1; $q2=($count-1)*9+2; $q3=($count-1)*9+3; $q4=($count-1)*9+4; $q5=($count-1)*9+5; $q6=($count-1)*9+6; $q7=($count-1)*9+7; $q8=($count-1)*9+8; $q9=($count-1)*9+9; echo '<table width="100%" border="1" cellpadding="0" cellspacing="0" bordercolor="#999999" bgcolor="#FFFFFF"><tr><th>Assignment Name</th> <th>Attempt Times</th><th>First Grade</th><th>Time</th><th>Second Grade<th>Time</th><th>Third Grade</th><th>Time</th><th>Final Grade</th></tr>'; echo '<tr> <td>'.$row[$q1].'</td> <td>'.$row[$q2].'</td> <td>'.$row[$q3].'</td> <td>'.$row[$q4].'</td> <td>'.$row[$q5].'</td> <td>'.$row[$q6].'</td> <td>'.$row[$q7].'</td> <td>'.$row[$q8].'</td> <td>'.$row[$q9].'</td> </tr>'; ++$count; echo "<br>"; } }} echo '</table>';
//else { //echo '<p>You do not have any grade until now.</p>';//}echo '<p><a href="home.php">Return</a></p>';?><title><?php echo TITLE;?></title>
没有输入数据的table和输入了数据的table格式是不一样的。。。
怎么让我这三个table看起来更整洁一些?就是每一项的宽度,格式一样。。。 展开
//else { //echo '<p>You do not have any grade until now.</p>';//}echo '<p><a href="home.php">Return</a></p>';?><title><?php echo TITLE;?></title>
没有输入数据的table和输入了数据的table格式是不一样的。。。
怎么让我这三个table看起来更整洁一些?就是每一项的宽度,格式一样。。。 展开
2个回答
展开全部
<?php
session_start();
echo "Hello! ^_^ ".$_SESSION['first_name'];
define('TITLE','Grade');
$dbc= mysql_connect("localhost","root","") or die("error");
mysql_select_db("project",$dbc);
$id=$_SESSION['student_id'];
$a=mysql_query("SELECT * FROM grade WHERE student_id ='$id'");
while ($row=mysql_fetch_array($a)){
$n=(count($row)/2-1)/9;
$row2=array_unique($row);
$row3=count($row2);
if($row3==1){
echo '<p>You do not have any grade until now.</p>';
}
else{
$count=1;
while($count<=$n){
$q1=($count-1)*9+1;
$q2=($count-1)*9+2;
$q3=($count-1)*9+3;
$q4=($count-1)*9+4;
$q5=($count-1)*9+5;
$q6=($count-1)*9+6;
$q7=($count-1)*9+7;
$q8=($count-1)*9+8;
$q9=($count-1)*9+9;
echo '<氏渗table width="100%" table-layout="fixed" border="1" cellpadding="0" cellspacing="0" bordercolor="#999999" bgcolor="#FFFFFF"><tr><th>Assignment Name</th>
<th>Attempt Times<渣核拿/th><th>First Grade</th><th>Time</th><th>Second Grade<th>Time</th><如搭th>Third Grade</th><th>Time</th><th>Final Grade</th></tr>';
echo '<tr>
<td width="70">'.$row[$q1].'</td>
<td width="70">'.$row[$q2].'</td>
<td width="70">'.$row[$q3].'</td>
<td width="70">'.$row[$q4].'</td>
<td width="70">'.$row[$q5].'</td>
<td width="70">'.$row[$q6].'</td>
<td width="70">'.$row[$q7].'</td>
<td width="70">'.$row[$q8].'</td>
<td width="70">'.$row[$q9].'</td>
</tr>';
++$count;
echo "<br>";
}
}
}
echo '</table>';
//else {
//echo '<p>You do not have any grade until now.</p>';
//}
echo '<p><a href="home.php">Return</a></p>';
?>
<title><?php echo TITLE;?></title>
在table属性中加table-layout="fixed",td设置一个宽度,就可以了。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询