gpt4 book ai didi

php - mysql代码没问题。 Php 无法回显它。为什么?

转载 作者:行者123 更新时间:2023-11-30 23:16:08 26 4
gpt4 key购买 nike

我是 PHP 新手。这段 mysql 代码 100% 在 phpmyadmin 中运行。我正在使用 <?php echo $row['Rank'];?>但我只为所有学生得到 1。也许我不擅长附和。请帮助我。

Select Distinct regd, Roll_no, Name_of_Student, Test_date,
English, f_eng, Mizo, f_mz, Hindi, f_hn, Mathematics, f_maths, SS, f_ss, Science,
f_sc, score, fmscore, perc, Rank FROM (SELECT *, IF(@marks = (@marks := score), @auto,
@auto := @auto + 1) AS Rank FROM
(SELECT regd, Roll_no, Name_of_Student, Test_date,
SUM( IF( `Subject` = 'English', Mark_score, 0 ) ) AS English,
SUM( IF( `Subject` = 'English', Full_mark, 0 ) ) AS f_eng,
SUM( IF( `Subject` = 'Mizo', Mark_score, 0 ) ) AS Mizo,
SUM( IF( `Subject` = 'Mizo', Full_mark, 0 ) ) AS f_mz,
SUM( IF( `Subject` = 'Hindi', Mark_score, 0 ) ) AS Hindi,
SUM( IF( `Subject` = 'Hindi', Full_mark, 0 ) ) AS f_hn,
SUM( IF( `Subject` = 'Mathematics', Mark_score, 0 ) ) AS Mathematics,
SUM( IF( `Subject` = 'Mathematics', Full_mark, 0 ) ) AS f_maths,
SUM( IF( `Subject` = 'SS', Mark_score, 0 ) ) AS SS,
SUM( IF( `Subject` = 'SS', Full_mark, 0 ) ) AS f_ss,
SUM( IF( `Subject` = 'Science', Mark_score, 0 ) ) AS Science,
SUM( IF( `Subject` = 'Science', Full_mark, 0 ) ) AS f_sc,
SUM(Full_mark) AS fmscore,
SUM(Mark_score) AS score, SUM(Mark_score)/SUM(Full_mark)*100 as perc FROM cxexam,
(SELECT @auto := 0, @marks := 0) AS init GROUP BY regd ORDER BY score DESC) t) AS result where Test_date between '2013-07-01' and '2013-07-31'

这是 PHP 部分。好像没问题它还正确地回应了一切,除了它没有正确输出排名。在排名行中它只显示 1作为所有学生的排名。您可以从下面的代码中了解我想要实现的目标。我真的需要你的帮助。我知道你们很熟悉这样的问题。

<table width="800" border="1" class="tablestyle" cellpadding="8" cellspacing="6">
<tr>
<th align="center" width="80">Roll No</th>
<th align="center" width="100">Name_of_Student</th>
<th align="center" width="40">English</th>
<th align="center" width="55">Mizo</th>
<th align="center" width="55">Hindi</th>
<th align="center" width="55">Math</th>
<th align="center" width="70">SS</th>
<th align="center" width="40">Science</th>
<th align="center" width="70">FM</th>
<th align="center" width="70">MO</th>
<th align="center" width="40">Percentage</th>
<th align="center" width="40">Rank</th>
<th align="center" width="40">Result</th>

</tr>
<?php
while($row=mysql_fetch_array($res))
{
?>
<tr>
<td align="center"><?php echo $row['Roll_no'];?></td>
<td align="left"><?php echo $row['Name_of_Student'];?></td>
<td align="center"><?php echo $row['English'];?></td>
<td align="center"><?php echo $row['Mizo'];?></td>
<td align="center"><?php echo $row['Hindi'];?></td>
<td align="center"><?php echo $row['Mathematics'];?></td>
<td align="center"><?php echo $row['SS'];?></td>
<td align="center"><?php echo $row['Science'];?></td>
<td align="center"><?php echo $row['fmscore'];?></td>
<td align="center"><?php echo $row['score'];?></td>
<td align="center"><?php echo number_format($row['perc'],0);?>%</td>
<td><?php echo $row['Rank']; ?></td>
<td><?php
if ($row['English']/$row['f_eng']*100>=40 && $row['Mizo']/$row['f_mz']*100>=40 && $row['Hindi']/$row['f_hn']*100>=40 && $row['Mathematics']/$row['f_math']*100>=40 && $row['SS']/$row['f_ss']*100>=40 && $row['Science']/$row['f_sc']*100>=40)
{
echo "<font color=green>Passed</font>";
}
else
{
echo "<font color=red>Failed</font>";
}
?></td>

</tr>
<?php
}
?>
</table>

最佳答案

可以只给出概述来完成这个东西。

$sql_q="<!--put your Query Here.-->";
$res=mysql_query($sql_q);

<!--Now Make a Table to Present all the Things-->

<table>
<tr>
<th>English</th>
<th>Mizo</th>
<th>Hindi</th>
<th>Math</th>
<th>SS</th>
<th>Science</th>
</tr>
<?php
while($row=mysql_fetch_array($res))
{
?>
<tr>
<td><!--Your Data for Each Columns--></td>
<!-- Example to print Roll No-->
<td><?php echo $row['Roll_no'];?></td>


</tr>
<?php
}
?>

</table>

关于php - mysql代码没问题。 Php 无法回显它。为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17760397/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com