pic.php
- PHP code
-
<?php $host="localhost"; $user="root"; $password="123456"; $database="teacher"; $table_name="student"; $conn=mysql_connect($host,$user,$password); echo "1111"; if(!mysql_connect($host,$user,$password)) die("connect erroring..... ".mysql_error()); mysql_select_db($database,$conn); // mysql_query("SET NAMES 'GB2312'"); //blob 类型是二进制的,不需要设置语言编码 $result=mysql_query("select * from student where picnum=$_GET[picnum]"); $row=mysql_fetch_object($result); Header("Content-type:image/gif"); echo $row->pic; ?>
主程序
- PHP code
-
<html> <HEAD> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <HEAD> <body> <?php $host="localhost"; $user="root"; $password="123456"; $database="test1"; $table_name="teacher"; $conn=mysql_connect($host,$user,$password); if(!mysql_connect($host,$user,$password)) die("connect erroring..... ".mysql_error()); mysql_select_db($database,$conn); mysql_query("SET NAMES 'GB2312'"); $v_find="select picnum from teacher"; $result=mysql_query($v_find,$conn) ; while($row=mysql_fetch_object($result)) { echo "<img src='pic.php?picnum=".$row->picnum."'>"; } ?> </body> </html>