| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2714 人关注过本帖
标题:php做产品发布系统,显示的时候怎么样能一行显示三条记录里的图片?
只看楼主 加入收藏
wuwenquan
Rank: 1
等 级:新手上路
帖 子:55
专家分:0
注 册:2006-4-21
结帖率:100%
收藏
 问题点数:0 回复次数:5 
php做产品发布系统,显示的时候怎么样能一行显示三条记录里的图片?
php做产品发布系统,显示的时候怎么样能一行显示三条记录里的图片,其他的自动换到下一行??

请给个例子,多谢
搜索更多相关主题的帖子: php 系统 记录 例子 自动 
2008-07-23 09:30
SkyGull
Rank: 5Rank: 5
来 自:浙江杭州
等 级:贵宾
威 望:13
帖 子:839
专家分:324
注 册:2007-6-7
收藏
得分:0 
看你是用什么做的了
用td是要循环++判断下就可以...

如果用div的话完全可以写在样式表里,有样式来控制
2008-07-23 12:21
ming206
Rank: 2
来 自:重庆
等 级:等待验证会员
威 望:3
帖 子:545
专家分:7
注 册:2005-8-2
收藏
得分:0 
简单的表循环,,解决方法之一:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.
<html xmlns="http://www.
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>手把手叫你如何循环Table-----之方法一:</title>
</head>
<body>
<table   border="0" cellpadding="2" cellspacing="1" bgcolor="#336699">
  <?php
    //假设你查询出来的数据结构是这样的:  
    $array_rs=array(0=>array("id"=>"1","photoName"=>"图片000","photoRoot"=>"img/0_0.gif"),
                    1=>array("id"=>"2","photoName"=>"图片111","photoRoot"=>"img/0_1.gif"),
                    2=>array("id"=>"3","photoName"=>"图片222","photoRoot"=>"img/0_2.gif"),
                    3=>array("id"=>"4","photoName"=>"图片333","photoRoot"=>"img/1_0.gif"),
                    4=>array("id"=>"5","photoName"=>"图片444","photoRoot"=>"img/1_1.gif"),
                    5=>array("id"=>"6","photoName"=>"图片555","photoRoot"=>"img/1_2.gif"),
                    6=>array("id"=>"7","photoName"=>"图片666","photoRoot"=>"img/2_0.gif"),
                    7=>array("id"=>"8","photoName"=>"图片777","photoRoot"=>"img/2_1.gif")   
                   );           
  ?>
  <tr>
    <?php
    for($i=0;$i<count($array_rs);$i++)
    {
    ?>
    <td bgcolor="#FFFFFF"><table width="100%" border="0" cellpadding="1" cellspacing="1">
      <tr>
        <td><img name="" src="<?=$array_rs[$i]["photoRoot"]?>"  border="0"  alt="<?=$array_rs[$i]["photoName"]?>" /></td>
      </tr>
      <tr>
        <td><?=$array_rs[$i]["photoName"]?></td>
      </tr>
    </table>
    </td>
    <?php
      if( ($i+1) % 3==0) echo "<tr>";
    }
    ?>
  </tr>
</table>
</body>
</html>

外贸综合平台:E贸通
2008-07-25 17:17
ming206
Rank: 2
来 自:重庆
等 级:等待验证会员
威 望:3
帖 子:545
专家分:7
注 册:2005-8-2
收藏
得分:0 
解决办法之二:循环个行,列(并且带有一定的计算)



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.
<html xmlns="http://www.
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>手把手叫你如何循环Table-----之方法二:</title>
</head>
<body>
<table   border="0" cellpadding="2" cellspacing="1" bgcolor="#336699">
  <?php
    //假设你查询出来的数据结构是这样的:
    $array_rs=array(0=>array("id"=>"1","photoName"=>"图片000","photoRoot"=>"img/0_0.gif"),
                    1=>array("id"=>"2","photoName"=>"图片111","photoRoot"=>"img/0_1.gif"),
                    2=>array("id"=>"3","photoName"=>"图片222","photoRoot"=>"img/0_2.gif"),
                    3=>array("id"=>"4","photoName"=>"图片333","photoRoot"=>"img/1_0.gif"),
                    4=>array("id"=>"5","photoName"=>"图片444","photoRoot"=>"img/1_1.gif"),
                    5=>array("id"=>"6","photoName"=>"图片555","photoRoot"=>"img/1_2.gif"),
                    6=>array("id"=>"7","photoName"=>"图片666","photoRoot"=>"img/2_0.gif"),
                    7=>array("id"=>"8","photoName"=>"图片777","photoRoot"=>"img/2_1.gif")   
                   );
    //先获得总行数
    $row= count($array_rs) / 3 ;
    //循环个行
    for($r=0;$r<$row;$r++){                              
  ?>
  <tr>
    <?php
    //循环列,固定3列
    for($c=0;$c<3;$c++)
    {
      //确定行,列位置:
      $index_row_cel= $r*3+$c ; //为什么乘以3呢,因为3列换嘛
      //如果比总记录还多,直接退出
      if($index_row_cel>=count($array_rs)) return ;
    ?>
    <td bgcolor="#FFFFFF"><table width="100%" border="0" cellpadding="1" cellspacing="1">
      <tr>
        <td><img name="" src="<?=$array_rs[$index_row_cel]["photoRoot"]?>"  border="0"  alt="<?=$array_rs[$index_row_cel]["photoName"]?>" /></td>
      </tr>
      <tr>
        <td><?=$array_rs[$index_row_cel]["photoName"]?></td>
      </tr>
    </table>
    </td>
    <?php
    } //----列循环结束
    ?>
  </tr>
  <?php
   }// ----行循环结束
  ?>
</table>
</body>
</html>

[[it] 本帖最后由 ming206 于 2008-7-25 17:24 编辑 [/it]]

外贸综合平台:E贸通
2008-07-25 17:18
ming206
Rank: 2
来 自:重庆
等 级:等待验证会员
威 望:3
帖 子:545
专家分:7
注 册:2005-8-2
收藏
得分:0 
解决办法之三 :利用DIV+CSS控制


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.
<html xmlns="http://www.
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>手把手叫你如何循环DIV-----之方法三:</title>
<style type="text/css">
<!--
.DataList {
    border: 1px solid #336699;
    margin: 5px;
    width: 600px;
    clear: both;
    overflow: auto;
}
.DataList .photo_c {
    width: 160px;
    height: 160px;
    float: left;
    border: 1px dashed #666633;
    margin: 5px;
    overflow: auto;
}
-->
</style>
</head>
<body>
<?php
//假设你查询出来的数据结构是这样的:
$array_rs=array(0=>array("id"=>"1","photoName"=>"图片000","photoRoot"=>"img/0_0.gif"),
                1=>array("id"=>"2","photoName"=>"图片111","photoRoot"=>"img/0_1.gif"),
                2=>array("id"=>"3","photoName"=>"图片222","photoRoot"=>"img/0_2.gif"),
                3=>array("id"=>"4","photoName"=>"图片333","photoRoot"=>"img/1_0.gif"),
                4=>array("id"=>"5","photoName"=>"图片444","photoRoot"=>"img/1_1.gif"),
                5=>array("id"=>"6","photoName"=>"图片555","photoRoot"=>"img/1_2.gif"),
                6=>array("id"=>"7","photoName"=>"图片666","photoRoot"=>"img/2_0.gif"),
                7=>array("id"=>"8","photoName"=>"图片777","photoRoot"=>"img/2_1.gif")   
               );
           
?>
<center>
<div class="DataList">
  <?php
  //啥也别管,直接循环(前提是你必须设置好DIV的宽度,这是用来控制的)
  for($i=0;$i<count($array_rs);$i++)
  {
  ?>
  <div class="photo_c">
  <img name="" src="<?=$array_rs[$i]["photoRoot"]?>"  border="0"  alt="<?=$array_rs[$i]["photoName"]?>" />
  </div>
  <?php
  }
  ?>
</div>
</center>
</body>
</html>

外贸综合平台:E贸通
2008-07-25 17:19
gogal
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2010-10-29
收藏
得分:0 
用wordpress怎么做个广告展示单页?

[url=http://www.]肇庆SEO[/url]
2010-10-29 09:54
快速回复:php做产品发布系统,显示的时候怎么样能一行显示三条记录里的图片?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.013132 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved