现有一张表:a,字段如下: pid int 4   图片编号 
 pic1 image max   图片照片1 
 pic2 image max   图片照片2 
 pic3 image max   图片照片3 
 pic4 image max   图片照片4 
 opcode varchar(20) 20   操作员 
 opdate datetime 8  (getdate()) 操作日期 里面现有数据3条,pid为8,9,10我想循环显示出来每条记录的4张图片,如何做呀?

解决方案 »

  1.   

    //pic.php<?
    header("Content-type:image/ "); 
    // Server in the this format: <computer>\<instance name> or // <server>,<port> when using a non default port number$server = 'KALLESPC\SQLEXPRESS';
    $link = mssql_connect('192.168.1.11:1433', 'sa', '123');if(!$link)
    {
        die('Something went wrong while connecting to MSSQL');
    }
    else{
        mssql_select_db('DATABASE_DATA', $link);
        //$version = mssql_query('SELECT * from RGraph');    //$sql ="EXEC WhateverSProcYouWant some_arguments"; $data = mssql_query('SELECT * from RGraph where sn = 783', $link); 
    $row=mssql_fetch_array($data); 
    echo $row["sFile"]; 

     
      

  2.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    </head><body>
    <table width="100%" border="0">
      <tr>
        <td><img border="0" src="pic.php" ></td>
      </tr>
    </table>
    </body>
    </html>
      

  3.   

    使用SQL SERVER 2005 + SQLServerDriver 的话自带的手册有具体的例子
    ---------------
    <?php
    /* Connect to the local server using Windows Authentication and
    specify the AdventureWorks database as the database in use. */
    $serverName = "(local)";
    $connectionInfo = array( "Database"=>"AdventureWorks");
    $conn = sqlsrv_connect( $serverName, $connectionInfo);
    if( $conn === false )
    {
         echo "Could not connect.\n";
         die( print_r( sqlsrv_errors(), true));
    }/* Set up the Transact-SQL query. */
    $tsql = "SELECT LargePhoto 
             FROM Production.ProductPhoto 
             WHERE ProductPhotoID = ?";/* Set the parameter values and put them in an array. */
    $productPhotoID = 70;
    $params = array( $productPhotoID);/* Execute the query. */
    $stmt = sqlsrv_query($conn, $tsql, $params);
    if( $stmt === false )
    {
         echo "Error in statement execution.</br>";
         die( print_r( sqlsrv_errors(), true));
    }/* Retrieve and display the data.
    The return data is retrieved as a binary stream. */
    if ( sqlsrv_fetch( $stmt ) )
    {
       $image = sqlsrv_get_field( $stmt, 0, 
                          SQLSRV_PHPTYPE_STREAM(SQLSRV_ENC_BINARY));
       header("Content-Type: image/jpg");
       fpassthru($image);
    }
    else
    {
         echo "Error in retrieving data.</br>";
         die(print_r( sqlsrv_errors(), true));
    }/* Free statement and connection resources. */
    sqlsrv_free_stmt( $stmt);
    sqlsrv_close( $conn);
    ?>
    ------
    SQL SERVER 2000 用 MSSQL扩展库的话,我现在没环境也没法具体测试
      

  4.   

    谢谢jaxio的源码,可是显示为红叉叉:<?
      header(" Content-type:image/  "); 
      $hostname   =   "localhost";   //MSSQL   Server 
      $dbuser   =   "sa";   //用户名    
      $dbpasswd   =   "sa";   //密码  
      $database="library"; 
      $conn   =   mssql_connect($hostname,$dbuser,$dbpasswd)   or   die("无法连接数据库服务器!");  
      mssql_select_db($database,$conn) or die("无法连接数据库$database");
      $sql      = "SELECT * FROM   P_picimg  where pid=9";
      $result   = @mssql_query($sql)   or   die("无法执行SQL:".$sql);   
      $row=mssql_fetch_array($result);
          
       echo $row["pic1"];
       //@header("Content-type: " . image_type_to_mime_type($row[pic1]));
       mssql_close($conn);?>
      

  5.   


    你好,我的操作是php+sql server 2000
      

  6.   

    php获取值,html显示咯?  
    报错是怎么样?
      

  7.   

    php获取值,html显示咯? 
    报错是怎么样?我就是在一个页面显示,另外一张页面调用数据,没有报错哦~
    程序就是上面的程序,显示页面为:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    </head><body>
    <table width="100%" border="0">
      <tr>
        <td><img border="0" src="test.php" ></td>
      </tr>
    </table>
    </body>
    </html>
      

  8.   

    第一行: header("Content-type:image/ "); 
    补上你的图片类型  image_type_to_mime_type($row[pic1]);