第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

如何為 codeigniter 中的特定列數(shù)據(jù)賦予顏色?

如何為 codeigniter 中的特定列數(shù)據(jù)賦予顏色?

PHP
蠱毒傳說 2022-12-11 09:41:14
<?    foreach($customer as $customer_details)    {?>        <tr id="customer_details_<?=$customer_details['id']?>">            <?                 foreach($dyncust_fields as $dyncust_field)                {                    if($dyncust_field['add_to_listing']=='1')                    {                        echo "<td style='color:green;'>".$customer_details[$dyncust_field['attribute_name']]."</td>";                    }                }            ?>        </tr>    <? }?>這里我寫了一些代碼來顯示動(dòng)態(tài)列的數(shù)據(jù),這里我想給特定列的特定數(shù)據(jù)一個(gè)顏色。但它不工作。這里這一行$customer_details[$dyncust_field['attribute_name']]是用來根據(jù)動(dòng)態(tài)列獲取表記錄的。在這里,$customer_details[$dyncust_field['attribute_name']] == 'cname'我希望單元格為紅色,否則顯示綠色。這個(gè)怎么做 ?。誰能幫幫我...
查看完整描述

2 回答

?
郎朗坤

TA貢獻(xiàn)1921條經(jīng)驗(yàn) 獲得超9個(gè)贊

<?php

    foreach($customer as $customer_details)

    {?>

        <tr id="customer_details_<?=$customer_details['id']?>">

            <? 

                foreach($dyncust_fields as $dyncust_field)

                {

                    if($dyncust_field['add_to_listing']=='1')

                    {

                       $color = $customer_details[$dyncust_field['attribute_name']] == 'cname' ?'red':'green';

                       $search = array("{{color}}","{{data}}");

                       $replace = array($color,$customer_details[$dyncust_field['attribute_name']] );

                       $template =  "<td style='color:{{color}};'>{{data}}</td>";

                       echo str_replace($search,$replace,$template);

                    }

                }

            ?>

        </tr>

    <? }

?>

這$template是表格單元格的模板。$search數(shù)組中的值替換為$replace數(shù)組的值。這樣,你只需要自定義模板,搜索和替換數(shù)組。例如,以下是您在評論部分提出的問題的答案。


$template = "<td> <a href='#list-corp-client' class='view-asset-inbox-model m-r-5 text-info' data-from='corporate' data-id='{{id}}' data-pk='1' data-toggle='modal'>{{title}}</a> </td>";

$search = array("{{id}}","{{title}}");

$replace = array($customer_details['id'], $asset_details['title']);

echo str_replace($search,$replace,$template);


查看完整回答
反對 回復(fù) 2022-12-11
?
喵喵時(shí)光機(jī)

TA貢獻(xiàn)1846條經(jīng)驗(yàn) 獲得超7個(gè)贊

<?php

    foreach($customer as $customer_details)

    {?>

        <tr id="customer_details_<?=$customer_details['id']?>">

            <? 

                foreach($dyncust_fields as $dyncust_field)

                {

                    if($dyncust_field['add_to_listing']=='1')

                    {

                        echo "<td style='".$customer_details[$dyncust_field['attribute_name']] == 'cname' ?'color:red':'color:green'."'>".$customer_details[$dyncust_field['attribute_name']]."</td>";

                    }

                }

            ?>

        </tr>

    <? }

?>

或者您可以將類定義為內(nèi)聯(lián)樣式或外部樣式


<style>

  .text-red{

    color:red;

  }

  .text-green{

    color:green;

  }

</style>


<?php

    foreach($customer as $customer_details)

    {?>

        <tr id="customer_details_<?=$customer_details['id']?>">

            <? 

                foreach($dyncust_fields as $dyncust_field)

                {

                    if($dyncust_field['add_to_listing']=='1')

                    {

                       $styleClass = $customer_details[$dyncust_field['attribute_name']] == 'cname' ?'text-red':'text-green'

                       echo "<td class='$styleClass'>".$customer_details[$dyncust_field['attribute_name']]."</td>";

                    }

                }

            ?>

        </tr>

    <? }

?>


查看完整回答
反對 回復(fù) 2022-12-11
  • 2 回答
  • 0 關(guān)注
  • 103 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)