//PHP代码
if($create) {
//生成文件
$connect=@mysql_connect('localhost','用户名','密码');
$dbname='数据库名';
$select=mysql_select_db($dbname,$connect);
    $query="select image from imagetable";  
    $result=mysql_query($query);
$all=0;
   while($row=mysql_fetch_object($result))
{     $all=$all+1;
     echo $row->image;
  }
echo "<div>";
echo $all;
echo "</div>";
  }if($file!="") {    
//存储图片数据
//读入上传的图片数据
$connect=@mysql_connect('localhost','用户名','密码');
$dbname='数据库名';
$select=mysql_select_db($dbname,$connect);
$imagecontent=addslashes(fread(fopen($file,"r"),filesize($file)));
$query="insert into imagetable(id,image,filename,filetype) values ('','$imagecontent','$file_name','$file_type')";
    if($file!="none" and $file!="") {
mysql_query($query);
}
    
}
?>
<form name="form1" method="post" action="" enctype="multipart/form-data">
  <input type="file" name="file"><INPUT TYPE="hidden" name=create value=1>
  <input type="submit" name="confirm" value="Submit">
</form>
<?php
$timer->stop();
//print $timer->getRunTime();
?>
这是一个例子,参考一下,不过没有文字,

解决方案 »

  1.   

    多了后面的几行去掉,<?php
    $timer->stop();
    //print $timer->getRunTime();
    ?>
      

  2.   

    index.php
    <?php
    print 'myweb';//这一行你可以拿出文字来显示
    print"<IMG SRC='test.php' WIDTH='100' HEIGHT='200' BORDER=0 ALT=''>";//这一行显示出你的图片test.php只是从数据库中提取出一副图片,显示出来。
      

  3.   

    $dbresult=msql_query("select * from info", $handle);
    while($dbarray=msql_fetch_array($dbresult)) {
      echo "<li>".$dbarray["IDNumber"]."\n";
    }<IMG SRC='test.php?id=<? echo $dbarray["IDNumber"] ?>' WIDTH='100' HEIGHT='200' BORDER=0 ALT=''>
    可以将你咬得更具不同的id显示不同的图片。
      

  4.   

    // 读取文件内容 
    $filename = "test.jpg";
    $fp = fopen($filename,"rb"); // 若为WIN系统,则必须加上“b”
    while(!feof($fp))
    {
      $picture.=fread($fp,1024);
    }
    $picture = base64_encode($picture);
    fclose($fp);// 插入到MYSQL数据库
    $conn=mysql_connect("localhost","root","");
    @mysql_select_db("test",$conn);
    $query="insert into pic (filename,picture) values ('$filename','$picture')";
    $result=mysql_query($query);
    $id=mysql_insert_id();
    // 从MYSQL取数据
    $query="select * from pic where id='$id'";
    $result=mysql_query($query);
    $row=mysql_fetch_array($result);
    $data = base64_decode($row[picture]);
    // 显示图片
    header("Content-type: image/jpeg");
    echo $data;
      

  5.   

    我以前做过PHP项目,上面的代码写得都不错,你可以拿去用。
      

  6.   

    第一步,将你上边的数据表变成如下img     title          tpye
    www.jpg   dfdjfsdf       图<?
    mysql_connect(localhost,$dbuser,$dbpasswd) or die ("数据库连接失败");//其中$dbuser为用户名,$dbpasswd为密码
    $sql = "SELECT * FROM $table ORDER BY id DESC"; //其中$table为对应的数据表名称
    $result = mysql_db_query($dbname, $sql);//其中$dbname为你主机的数据库名
    $row = mysql_fetch_array($result);echo "<img src=./img/".$row[img]."><br>".$row[title]."";//其中./img/为你数据库图片所存放的子目录名称
    ?>