php提取数据库图片的问题

来源:百度知道 编辑:UC知道 时间:2024/06/25 02:32:38
我想做一个轮换显示新闻图片的效果 要从数据库调取最新的前五张新闻 代码如下:

<?php
$sql=mysql_query("select * from tb_news where ifdeleted=0 and type='最新活动' and iftp=0 order by input_date desc limit 0,1",$conn);
$info=mysql_fetch_array($sql);
do{
?>
imgUrl1="<?php echo getValue(str_replace("../","",$info[tupian]),"images/notitle.gif"); ?>";
imgtext1="<?php echo $info['title']; ?>";
imgLink1=escape("http://www.khs1930.com/gznews_detail.php?id=<?php echo $info[id]; ?>");
<?php }while ($info=mysql_fetch_array($sql)); ?>

<?php
$sql=mysql_query("select * from tb_news where ifdeleted=0 and type='最新活动' and iftp=0 order by input_date desc limit 1,2",$conn);
$info=mysql_fetch_array($sql);
do{
?>
imgUrl2=

<?php
//escape() 是你自己定义的函数你问我做啥/.?
//getValue也是你自己定义的 就不要来问我了
//无数据库未验证代码 你自己测下吧
$i=1;
$result = mysql_query("select * from tb_news where ifdeleted=0 and type='最新活动' and iftp=0 order by input_date desc limit 0,5");
$url='http://www.khs1930.com/gznews_detail.php?id=';
while($row = mysql_fetch_array($result))
{
echo 'imgUrl'.$i.'='.getValue(str_replace("../","",$row['tupian']),"images/notitle.gif");
echo 'imgtext'.$i.'='.$row['title'];
//echo 'imgLink'.$i.'='.escape($url.$row['id']);
echo 'imgLink'.$i.'='.$url.$row['id'];
$i++;
}

mysql_close($conn);
?>