我有一组存储在phpmyadmin中的多项选择题。我需要检索图像以及每个问题和答案。换句话说,当用户开始测试或点击“下一个问题”按钮时,他们不仅需要查看问题和答案,还需要查看与该问题相关的图像。我已经在数据库中以Blob格式保存了图像,但是有动态检索它们的问题。如果有人帮助我会很感激
以下是代码的一部分:
$singleSQL = mysql_query("SELECT * FROM questions WHERE id='$question' LIMIT 1");
while($row = mysql_fetch_array($singleSQL)){
$id = $row['id'];
$thisQuestion = $row['question'];
$type = $row['type'];
$question_id = $row['question_id'];
$q = '<h2><i>'.$thisQuestion.'</i></h2>';
$sql2 = mysql_query("SELECT * FROM answers WHERE question_id='$question' ORDER BY rand()");
while($row2 = mysql_fetch_array($sql2)){
$answer = $row2['answer'];
$correct = $row2['correct'];
$answers .= '<label style="cursor:pointer;"><input type="radio" name="rads" value="'.$correct.'"><b>'.$answer.'</b></label>
<input type="hidden" id="qid" value="'.$id.'" name="qid"><br /><br />
';
}
$sql3 = mysql_query("SELECT username FROM quiz_takers");
while($row3 = mysql_fetch_array($sql3)){
$name = $row3['username'];
}
答案 0 :(得分:0)
尝试这样的方法来显示blob图像:
$image = $row['image'];
echo '<img src="data:image/type;base64,'.base64_encode($image).'" />';
将image/type
替换为image/jpeg
或图像的任何类型。