<?php
$selectSQL="select COUNT(distinct 学号) from 成绩表"
$rowSet=mysql_query($selectSQL)
$selectSQL1="select * from 成绩表 order by 学号"
$resultSet1=mysql_query($selectSQL1)
while($student1=mysql_fetch_accos($resultSet1)){
$sid=$student1['学号']
$selectSQL2="select count(*) from 成绩表 where 学号=$sid"
$lession_cout=mysql_query($selectSQL2)
$selectSQL3="select 分数 from 成绩表 where 学号=$sid"
$resultSet3= $lession_cout=mysql_query($selectSQL3)
while($student3=mysql_fetch_accos($resultSet3)){
$score_sum= $score_sum + $student3[分数]
}
$average=$score_sum/$lession_cout
}
?>
<tr align="center">
<td height="21"><?php echo $sid?></td>
<td><?php echo $lession_cout?></td>
<td><?php echo $score_sum?></td>
<td><?php echo $average?></td>
</tr>
<?php
}
?>
<tr>
<td height="21" colspan="4">考试总人数:<?php echo $rowSet?></td>
</tr>
</table>
</body>
<?php
closeConnection()
?>
这样弄看行不?
echo"<table border=\"".$border."\"cellpadding=\"".$cellpadding."\"cellspacing=\"".$cellspacing."\">"这个语句是显示字符串和变量内容相叠加的一种写法。
echo"(这个双引号是php程序直接认定的)<table border=\"(这个双引号是显示在HTML中的引号)"(这个是PHP程序认定的).(这个小点,是php程序中用于连接的运算符)$border."(PHP)\"(HTML)cellpadding=\"(HTML)"(PHP).$cellpadding."(PHP)\"(HTML)cellspacing=\"(HTML)"(PHP).$cellspacing."(PHP)\"(HTML)>"(PHP)
这句话在HTML中打印完成的样子是:
<table border="1"cellpadding="4"cellspacing="4">
因为在PHP中采用了双引号做字符串的引号,那么其中想输出双引号,就要使用\" 的方式,这样,这个双引号就被PHP认为是字符串,而非PHP功能性的引号了。
当然,还有很多的方法可以实现相同的功能:
比如: echo "这个'小狗'是我的!" 打印出来后,单引号也被认为是字符串。
还有: echo '这个"小狗"是我的!' 这一行打印出来后,双引号被认定为字符串。
其实,在php中,单引号与双引号之间的使用是特别灵活的,这也是php程序的一大亮点,其它的程序在这方面做得有些不同,像php中,在特定的时候双引号之间的变量会被认定为变量,这个在其它程序中是不存在的功能。
首先是外面的循环用了$dosql->GetArray() 然后里面的循环又用了 $dosql->GetArray($row['id'])。$dosql是同一个吧,同一个就会在里面循环的时候把外面要循环的东西替换掉了。欢迎分享,转载请注明来源:内存溢出
评论列表(0条)