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 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog