三家商店排成一排 [英] Three shop offers in row

查看:163
本文介绍了三家商店排成一排的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

    if(count($offer_list['item']) > 0)
{
  $main_content .= '<table cellspacing="2" cellpadding="2" width=30>';
  foreach($offer_list['item'] as $item)
  {
    $main_content .= '<td class="shop">
    <a class="shop" style="display: block;" href="/shop/item/id/'.$item['id'].'">
    <center><img src="item_images/'.$item['item_id'].'.gif"><br><font color="white"><b>'.$item['name'].'</font></b><font color="red"> <b> '.$item['points'].' points</font></b>';
    if(!$logged)
    {
      $main_content .= '<p><b><a href="/account">[Login to buy]</a></b>';
    }
    else
    {
  $main_content .= '<br><b><font size=1 color="white">Your points balance is: '.$user_premium_points;
      $main_content .= '<br><font color="white"> <fieldset class="shop"><legend>DESCRIPTION</legend>'.$item['description'].'</fieldset></font><br><font color="white"><b> [Click to buy] </b></font></form> </a></center></td>';
    }
    $main_content .= '';
  }
  $main_content .= '</tr></table>';
}

如何让它像行中的三个优惠一样?现在我有一排,所有报价都在一行;我只想在tr和循环中显示最多三个td。

How to make it like only three offers in row? NOW I have one row and all offer is in one line; I just want to show max three td in tr and loop.

推荐答案

如果你只需要连续3个td,建立它进入你的循环:

if you only want 3 tds in a row, build it into your loop:

    //opener

    <table>
    //1st row
    foreach($offer_list['item'] as $item) {


    content.= <tr>;
    content.= <td>$item[id]</td><td>$item[image]</td><td>$item[etc]</td>;
    content.= <tr>;

    //2nd row
    content.= <tr>;
    content.= <td>$item[description]</td><td>$item[etc]</td><td>$item[etc]</td>;
    content.= <tr>;

    }
    content.=</table> //or div, etc

但是听起来你想要像产品一样定位元素?为此使用内联div。 (除非你详细说明你想做什么,否则在一个例子中没有意义..)

however it sounds like you want to position elements around like a product? Use inline divs for this. (no point in a example unless you elaborate what you want to do..)

这篇关于三家商店排成一排的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆