php
  • table
  • row
  • 2014-03-06 43 views 0 likes 
    0
    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>'; 
    } 
    

    如何使它像行中只有3個優惠現在我有一排,所有報價是在1行|我只是想顯示在TR最多3個TD和循環3排商店優惠

    +0

    只要看看HTML中的表格是如何工作的,例如http://www.peachpit.com/articles/article.aspx?p=2128064 – d4Rk

    +0

    你在'foreach'前面忘了開頭''... – djot

    +0

    這個問題很難理解... – Andrew

    回答

    0

    如果你只是想在一排3個TDS,其打造成爲你的循環:

    //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。 (除非你詳細說明你想做什麼,否則沒有意義。)

    相關問題