我何时使用此代码:
$emailc = 'thomas990428@me.com_classes';
$emaila = 'thomas990428@me.com_assignments';
$emailp = 'thomas990428@me.com_projects';
$resulty = mysqli_query($con,"SELECT * FROM `$emailc` ORDER BY period"); if (!$result) echo mysqli_error(); else // ok, do your thing.
$resulti = mysqli_query($con,"SELECT * FROM `$emaila` ORDER BY duehw"); if (!$result) echo mysqli_error(); else // ok, do your thing.
$resulto = mysqli_query($con,"SELECT * FROM `$emailp` ORDER BY dueproj"); if (!$result) echo mysqli_error(); else // ok, do your thing.
$classcount = 1;
while($row = mysqli_fetch_array($resulty))
{
$period = $row['period'];
$teacher = $row['teacher'];
$subject = $row['subject'];
$subjecto = strtolower($subject);
$subjecto = str_replace(' ', '', $subjecto);
$grade = $rowy['grade'];
echo "<section id='" . $subjecto . "'> \n";
echo "<p class='title'>" . $subject . "</p> \n";
echo "<a style='cursor:pointer;' onclick='homework" . $classcount . "()'>Homework </a>|<a style='cursor:pointer;' onclick='projects" . $classcount . "()'> Projects</a> \n";
echo "<div id='homework" . $classcount . "'><br /><a onclick='addassignment()'>Add Assignment</a><br />";
echo "<table class='homework'>";
echo "<tr>";
echo "<th class='title'>";
echo "Title";
echo "</th>";
echo "<th class='duedate'>";
echo "Due Date";
echo "</th>";
echo "</tr>";
while($row = mysqli_fetch_array($resulti))
{
$subjecthw = $row['subjecthw'];
$namehw = $row['namehw'];
$duehw = $row['duehw'];
echo "<tr>";
echo "<td class='title'>";
echo $namehw;
echo "</td>";
echo "<td class='duedate'>March ";
echo $duehw;
echo "</td>";
echo "</tr>";
}
echo "</table>";
echo "</div> \n";
echo "<div id='projects" . $classcount . "'><br /><a onclick='addassignment()'>Add Assignment</a><br />";
echo "<table class='homework'>";
echo "<tr>";
echo "<th class='title'>";
echo "Title";
echo "</th>";
echo "<th class='duedate'>";
echo "Due Date";
echo "</th>";
echo "</tr>";
while($row = mysqli_fetch_array($resulto))
{
$subjectproj = $row['subjectproj'];
$nameproj = $row['nameproj'];
$dueproj = $row['dueproj'];
echo "<tr>";
echo "<td class='title'>";
echo $nameproj;
echo "</td>";
echo "<td class='duedate'>March ";
echo $dueproj;
echo "</td>";
echo "</tr>";
}
echo "</table>";
echo "</div> \n";
echo "</section> \n";
$classcount += 1;
}
我只在一节中获得了hw和proj。我做错了吗?谢谢!我知道它可能永远不会工作,但我该如何解决?我有3个表,我需要从所有表中获取数据。
答案 0 :(得分:0)
请勿在{{1}}循环中使用$row
。
e.g
while
也没有时间浏览代码,但在循环中运行SQL绝不是一个好主意。