取数据:其中字段book_image是LONGBLOB类型,其中的数据是二进制图片,数据库是mysql5.0
$sql="select * from t_new_book2 where book_image<>'' limit 0,10";
$result=mysql_query($sql);if(mysql_num_rows($result)>0)
{
$i=1;
while($rows=mysql_fetch_object($result))
{
header( "Content-type: image/gif");
?>
<tr>
<td><?=$rows->book_name?></td>
    <td><?=$rows->book_image?></td>
</tr>
<?
}
}
mysql_free_result($result);通过以上方式获取数据,速度很慢,请问有什么方法可以解决这个问题?

解决方案 »

  1.   

    $sql="select book_name, book_image from t_new_book2 where book_image<>'' limit 0 ,10 ";
    $result=mysql_query($sql);if(mysql_num_rows($result)>0)
    {
    $i=1;
    while($rows=mysql_fetch_assoc($result))
    {
    header( "Content-type: image/gif");
    ?>
    <tr>
    <td> <?php echo $rows['book_name'];?> </td>
    <td> <?php echo $rows['book_image'];?> </td>
    </tr>
    <?
    }
    }
    mysql_free_result($result); 
      

  2.   

    试试看:$sql="select * from t_new_book2 where book_image !='' limit 0,10"; 
      

  3.   

    可能我没有说清楚,因为book_image这个字段是LONGBLOB,里面保存的是图片,现在的问题是怎么样取里面的图片,显示在页面上
      

  4.   

    要分清,-> 与 =>, 前一个是调用方法。后一个是调用字段。
      

  5.   

    向来不将图片二进制数据存入数据库的人路过
    本人只将图片的URL存入数据库
      

  6.   

    楼上是正确的,存数据库那不是找抽吗?
    这么大的数据流,增加数据库和PHP内存使用压力。