我正在尝试找到一种方法来输出插入到愚蠢数据库中的任何BLOB文件。在我查询CV列的代码中,我得到了各种奇怪的符号。你能帮我解决一下我的代码吗?
$crud->dataview($query);
}else{
$query = "SELECT id, from_unixtime(cheie_wp) as `datetime`, nume, prenume, email, telefon, oras, denumiri_job, cv FROM jobselection_data_old ORDER BY id DESC";
$records_per_page=10;
$newquery = $crud->paging($query,$records_per_page);
$crud->dataview($newquery);
public function dataview($query)
{
$stmt = $this->db->prepare($query);
$stmt->execute();
if($stmt->rowCount()>0)
{
while($row=$stmt->fetch(PDO::FETCH_ASSOC))
{
$date_in = $row['datetime'];
$date_out = explode(' ', $date_in);
?>
<tr>
<td><?php echo $date_out[0]; ?></td>
<td><?php print($row['nume']); ?></td>
<td><?php print($row['prenume']); ?></td>
<td><?php print($row['email']); ?></td>
<td><?php print($row['telefon']); ?></td>
<td><?php print($row['oras']); ?></td>
<td><?php print($row['denumiri_job']); ?></td>
<td align="center"><?php
if($row['cv'] != NULL) { ?>
<a href="view.php?id=<?php print ($row['id']) ?>">view</a>
<?php }else{
echo '-';
}
?></td>
<td align="center">
<a href="edit-data.php?edit_id=<?php print($row['user_id']); ?>"><i class="glyphicon glyphicon-edit"></i></a>
</td>
<td align="center">
<a href="delete.php?delete_id=<?php print($row['user_id']); ?>"><i class="glyphicon glyphicon-remove-circle"></i></a>
</td>
</tr>
<?php
}
}else{ ... }
}
修改
我修改了我的代码,并使用以下代码添加了view.php:
if(isset($_GET['id']))
{
$stmt = $DB_con->prepare("SELECT cv FROM jobselection_data_old WHERE id=:id");
$stmt->execute(array(":id"=>$_GET['id']));
$stmt->bindColumn(1, $lob, PDO::PARAM_LOB);
$stmt->fetch(PDO::FETCH_BOUND);
header('content-type: image/jpeg');
echo $lob;
}
?>
问题是它不会生成我上传到数据库的图像文件。
您可以在https://ns.jobselection.ro/db/查看 user / pass:test
我还添加了我的数据库的屏幕截图:https://ns.jobselection.ro/db/screen.png。我只添加了一行用于测试目的!
答案 0 :(得分:0)