仅显示相应详细信息的一个名称

时间:2016-05-31 07:15:24

标签: php codeigniter

[1] => Array
    (
        [spid] => 21
        [name] => Gaurav
        [partner_acc_name] => SkyTechMasters

    )

[2] => Array
    (
        [spid] => 21
        [name] => Gaurav
        [partner_acc_name] => TestPartner

    )


    This is the array i have show above.

enter image description here

我希望" Gaurav"名称应显示为" Partner_acc_name"。

代码 -

<tr class="all_partner" for="<?php echo $get_partner_forecast_val['spid']; ?>">

                                    <td for="<?php echo $get_partner_forecast_val['spid']; ?>"rowspan="<?php echo ($product_no*2)+2; ?>"><?php echo $get_partner_forecast_val['name'];?></td>

                                    <td for="<?php echo $get_partner_forecast_val['spid']; ?>"rowspan="<?php echo ($product_no*2)+2; ?>"><?php echo $get_partner_forecast_val['partner_acc_name'];?></td>

                                    <td for="<?php echo $get_partner_forecast_val['spid']; ?>"  rowspan="<?php echo ($product_no*2)+2; ?>"><?php echo $get_partner_forecast_val['crm_acc_name'];?></td>

这是代码。

2 个答案:

答案 0 :(得分:0)

我现在在Jquery的帮助下解决了这个问题。

答案 1 :(得分:-1)

试试这个:

<?php
$temp = array();
    foreach($partner_forecast as $get_partner_forecast_val) {
?>
<tr class="all_partner" for="<?php echo $get_partner_forecast_val['spid']; ?>">

<td for="<?php echo $get_partner_forecast_val['spid']; ?>" rowspan="<?php echo ($product_no*2)+2; ?>">
    <?php if(!in_array($get_partner_forecast_val['name'], $temp)) echo $get_partner_forecast_val['name'];?>
</td>
<td for="<?php echo $get_partner_forecast_val['spid']; ?>" rowspan="<?php echo ($product_no*2)+2; ?>">
    <?php echo $get_partner_forecast_val['partner_acc_name'];?>
</td>
<td for="<?php echo $get_partner_forecast_val['spid']; ?>" rowspan="<?php echo ($product_no*2)+2; ?>">
    <?php echo $get_partner_forecast_val['crm_acc_name'];?>
</td>

</tr>
<?php
        if(!in_array($get_partner_forecast_val['name'], $temp))
            temp[] = $get_partner_forecast_val['name']; // add name to array which has been displayed so that we can check in next record whether its nedd to diaply or not
    }
?>