donglian1982 2010-09-14 22:02
浏览 492

在PHP脚本中显示BLOB文件

This is my PHP script which displays a radio station's schedule:

    <div class="divider"></div>
    <div class="main" style="width:552px;">
        <img src="$image" width=115 height=60>
        <div class="time">$airtime</div>
        <div class="show"><h3><a href="$link><b>$presenter</b></a></h3>
            <p>$showdesc</p></div>
        <div class="footer"></div>
    </div>
    </div>
                <div class="footer"></div>
                <div class="bottom"></div>
            </div>

The values with the dollar sign represent the field names in my database, which is radiopresenters.

How would I get this to work as a PHP script, and display the values from the database? All values in the fields are stored in TEXT format, apart from the image field which is stored in BLOB format.

Airtime is stored in a separate database entitled as radioschedule which has all 4 fields ib, and I intend to link these together via some relational means.

What's the best way to get it to display as the above, especially the BLOB part?

  • 写回答

3条回答 默认 最新

  • duanpu1963 2010-09-14 22:16
    关注

    Are you asking how to put those values into your file?

    As for the text ones you could just use

    <?=$airtime?> 
    

    or if your server setup doesn't support short tags just use

    <?php echo $airtime?>
    

    I would just do this inline with your php.

    Example:

    <div class="time"><?=$airtime?></div>
    

    As for the BLOB, I would advise not doing this and just storing the image on your server and store the image file's name in the db. BUT if you are intent on doing this I think the only way you can do this is by having a separate script that returns an image file. Something like this:

    <?php 
    // Do all your db stuff here, grab the blob file. Probably from a $_GET paramater
    $image = $row['image'];
    header("Content-type: image/jpeg"); // or gif, etc...
    echo $image;
    die();
    ?>
    

    Then in your other file you would do something like:

    <img src="imagescript.php?person_id=<?=$person_id?>" width=115 height=60>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败
  • ¥15 树莓派5怎么用camera module 3啊
  • ¥20 java在应用程序里获取不到扬声器设备
  • ¥15 echarts动画效果的问题,请帮我添加一个动画。不要机器人回答。
  • ¥15 Attention is all you need 的代码运行
  • ¥15 一个服务器已经有一个系统了如果用usb再装一个系统,原来的系统会被覆盖掉吗
  • ¥15 使用esm_msa1_t12_100M_UR50S蛋白质语言模型进行零样本预测时,终端显示出了sequence handled的进度条,但是并不出结果就自动终止回到命令提示行了是怎么回事: