我不知道如何在网上搜索答案,我不确定如何解释问题,所以如果不清楚或之前被问过,我很抱歉。
这是交易:我需要显示一些具有不同状态的项目(有“未回答”、“讨论中”和“已回答”)。现在发生的情况是显示未回答的问题,正在讨论的问题显示正确的文本,但已回答问题的文本与“讨论中”相同。当其中一个问题从“未回答”移至“讨论中”时,将显示“已回答”问题的正确文本。当没有“未回答”的问题时,该项目的文本是正确的。但是其他项目得到的文本与“未回答”相同,并且应该在“讨论中”中显示的问题不可见。
有人知道我能做些什么来解决这个问题吗?我会在下面放一些代码。谢谢!!!
overzicht.php
<?php
session_start();
if(!isset($_SESSION['views']))
{
header('Location: index.php');
}
else
{
$feedback = "";
try
{
include_once('classes/question.class.php');
$oQuestion = new Question();
$oQuestionsUnanswered = $oQuestion->getQuestionsUnanswered();
$oQuestionsInDiscussion = $oQuestion->getQuestionsInDiscussion();
$oQuestionsAnswered = $oQuestion->getQuestionsAnswered();
}
catch(Exception $e)
{
$feedback = $e->getMessage();
}
}
?>
显示不同的项目(对于其他 2 个状态重复两次,使用其他变量,例如 $oQuestionsAnswered):
<h3>Vragen onbeantwoord:</h3>
<div id="questionUnanswered">
<?php
if(isset($oQuestionsUnanswered))
{
$unanswered_details = "";
while($arr_unanswered = mysqli_fetch_array($oQuestionsUnanswered))
{
$unanswered_details .= "<div class='head'>";
$unanswered_details .= "<div class='titel'>";
$unanswered_details .= "<a href='full_topic.php?id=".$arr_unanswered['bericht_id']."'>".$arr_unanswered['bericht_titel']."</a></div>";
$unanswered_details .= "<div class='datum'>" . $arr_unanswered['bericht_datum'] . "</div></div>";
}
echo $unanswered_details;
}
else
{
echo $feedback;
}
?>
</div>
question.class.php(对于其他 2 个也重复)
public function getQuestionsUnanswered()
{
include('connection.class.php');
$sql = "SELECT *
FROM tblbericht
WHERE fk_status_id = 3;";
$result = $conn->query($sql);
if($result->num_rows!=0)
{
return $result;
}
else
{
throw new Exception("Er zijn momenteel nog geen onbeantwoorde vragen");
}
mysqli_close($conn);
}