如何用数据库表的下一个 blob 条目替换 blob 中的单词

我正在尝试构建一个页面,该页面能够读取表格并写下所选条目(时间、发件人、收件人、标题和内容),该页面工作正常。


我面临的问题是第一个内容条目是这样的文本 BLOB


ex.

TextTextTextTextTextText 

TextTextTextText

img1.jpg

TextTextTextTextText

TextTextTextTextTextText

将img1.jpg被保存在接下来的内容条目保存在BLOB,且必须编码要打印的图像Base64和现在,而试图把它写下来这样我被堵


TextTextTextTextTextText

TextTextTextText

(actual image from the next entry)

TextTextTextTextText

TextTextTextTextTextText

我试图检查strpos内容是否包含下一个 blob 的文件名,然后用实际图像替换它,但我无法在同一行中获取下一个表条目


这是正常输出的代码


$res = mysqli_query($link, createRequest(true, $link)) or die(mysqli_error($link));

while($row = mysqli_fetch_assoc($res)){


    $title = $row["a_subject"];

    $time = $row["create_time"];

    $sender = $row["a_from"];

    $reciever = $row["a_to"];

    $body = $row["content"];

    $articleid = $row["id"];


    if (strpos($body, '')){

        $img = "<pre>".'<img src="data:image/jpeg;base64,'.base64_encode( $body).'"/>'."</pre>"


    ?>

    <tr>

    <td><?php echo ($time) ?></td>

    <td><?php echo ($sender) ?></td>

    <td><?php echo ($reciever) ?></td>

    <td><?php echo ($title) ?></td>

    <td><?php echo $img ?></td>

    <td><a href=<?php echo "http://localhost/php/imageviewer.php?ArticleID=".$row["id"].""?>>Zeige Anhänge</a></td>

    </tr>

    <?php

    } else {

        ?>

    <tr>

    <td><?php echo ($time) ?></td>

    <td><?php echo ($sender) ?></td>

    <td><?php echo ($reciever) ?></td>

    <td><?php echo ($title) ?></td>

    <td><?php echo utf8_encode($body)?></td>

    <td><a href=<?php echo "http://localhost/php/imageviewer.php?ArticleID=".$row["id"].""?>>Zeige Anhänge</a></td>

    </tr>

    <?php

现在我正在检查内容是图像还是只是一些文本,然后将它们写下来。我想要发生的是,让我们说文本内容是:


text

img1

text

img2

text

img3 

我当前的解决方案我得到了 4 个 html 表条目,第一个是


text

img1.jpg

text

img2.jpg

text

img3 .jpg

第二个是


actual image of img1.jpg

第三个是


actual image of img2.jpg

等等


我最终想要的是一个看起来像这样的表条目


text

actual img1

text

actual img2

text

actual img3


慕娘9325324
浏览 197回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP