我在 loadimage.php 文件的一个查询中有两个 select 语句,并将其显示在两个不同的过程中,一个用于事件的图像,一个用于新闻的图像。我的代码是这样的
加载图像.php
<?php
mysql_connect("localhost","root");
mysql_select_db("pcnl");
$q="select * from tbl_event where event_ID = ".$_GET['id'];
$rec=mysql_fetch_array(mysql_query($q));
$image=$rec['event_img'];
header('Content-Length: '.strlen($image));
header("Content-type: image/".$rec['event_imgExt']);
echo $image;
$sqlmain="select * from tbl_news where news_ID = ".$_GET['mainid'];
$mainimg=mysql_fetch_array(mysql_query($sqlmain));
$mainimage=$mainimg['news_img'];
header('Content-Length: '.strlen($mainimage));
header("Content-type: image/".$mainimg['news_ext']);
echo $mainimage;
?>
事件.php
<img src="loadimage.php?id=<?php echo $events[id];?>" width="700px" height="350px">
新闻.php
<img src="loadimage.php?mainid=<?php echo $main['news_ID'];?>" width="300px" height="350px">