0

私は以下のコードを貼り付けています............私の問題はelse部分にあります。タグのプロパティが適用されていないため、フィールド幅が縮小しています。タグのプロパティがelse部分にも適用されるようにするにはどうすればよいですか。

注: 形式は同じである必要があります。

<?php 
    $network_name="";
    foreach($channel_summary as $c) {
        $channel_str = "";
        if($network_name!=$c['a']) { 
            $channel_str .= $c['a'].'~'.str_replace('/','surero',$c['b']).'~'.$c['c'].'~'.str_replace(' ','surero',$c['d']).'~'.date('d-M-Y', strtotime( $c['e'])).'~'.date('d-M-Y', strtotime( $c['f'])).'~'.$c['g'].'~'.$c['h'].'~'.str_replace('@','surero',$c['i']).'~'.str_replace(' ','surero',$c['j']).'~'.$c['k'];
?>
<br /><p>Network Name: <?php echo $c['a'];
    $network_name=$c['a'];?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  Network Contact: <?php echo $c['i'] ?> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <!--<input type="Submit" class= "submit" value="Network RO" onclick="javascript:NetworkROPDF(<?php echo $order_id ?>,'<?php echo $network_name;?>')" target="_blank" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-->
    <input type="Submit" class= "submit" value="Network RO PDF" onclick="javascript:NetworkRO(<?php echo $order_id ?>,'<?php echo $network_name;?>')" target="_blank" /></p>
<table><tr>
    <th>A</th>
    <th>B</th>
    <th>C</th>
    <th>D</th>
    <th>E</th>
    <th>F</th>
    <th> G</th>
    <th> H </th>
    <th>&nbsp;</th>
</tr>
<tr>
    <td><?php echo $c['b']."/".$c['a'] ?></td>
    <td><?php echo $c['c'] ?></td>
    <td><?php echo $c['d'] ?></td>
    <td><?php print date('d-M-Y', strtotime( $c['e']))  ?></td>
    <td><?php print date('d-M-Y', strtotime( $c['f']))     ?></td>
    <td><?php echo $c['g']  ?></td>
    <td><?php echo $c['h']?></td>
    <td><?php echo $c['g']* $c['h']?>
    <td><a href=javascript:add_price(<?php echo $order_id ?>,'<?php echo $channel_str;?>')>Add Price</a> </td>
</tr>
</table><?php } else
    {
        $channel_str .= $c['a'].'~'.str_replace('/','surero',$c['b']).'~'.$c['c'].'~'.str_replace(' ','surero',$c['d']).'~'.date('d-M-Y', strtotime( $c['e'])).'~'.date('d-M-Y', strtotime( $c['f'])).'~'.$c['g'].'~'.$c['h'].'~'.str_replace('@','surero',$c['i']).'~'.str_replace(' ','surero',$c['j']).'~'.$c['k'];
?><table>
<tr>
    <td><?php echo $c['b']."/".$c['a'] ?></td>
    <td><?php echo $c['c'] ?></td>
    <td><?php echo $c['d'] ?></td>
    <td><?php print date('d-M-Y', strtotime( $c['e']))  ?></td>
    <td><?php print date('d-M-Y', strtotime( $c['f']))     ?></td>
    <td><?php echo $c['g']  ?></td>
    <td><?php echo $c['h']?></td>
    <td><?php echo $c['g']* $c['h']?>
    <td><a href=javascript:add_price(<?php echo $order_id ?>,'<?php echo $channel_str;?>')>Add Price</a> </td>
</tr></table>
<?php }}?>
4

1 に答える 1

2

問題は、else 部分に別のテーブルを使用しているためです。このコードを試してください

<?php
 $network_name = "";
?>
<table>
<?php
foreach ($channel_summary as $c) {
    $channel_str = "";
    if ($network_name != $c['a']) {

        $channel_str .= $c['a'] . '~' . str_replace('/', 'surero', $c['b']) . '~' . $c['c'] . '~' . str_replace(' ', 'surero', $c['d']) . '~' . date('d-M-Y', strtotime($c['e'])) . '~' . date('d-M-Y', strtotime($c['f'])) . '~' . $c['g'] . '~' . $c['h'] . '~' . str_replace('@', 'surero', $c['i']) . '~' . str_replace(' ', 'surero', $c['j']) . '~' . $c['k'];
        ?>
        <tr>
            <td colspan="3">Network Name: <?php echo $c['a']; $network_name = $c['a']; ?></td>
            <td colspan="3">Network Contact: <?php echo $c['i'] ?></td>            
            <td colspan="3"><input type="Submit" class= "submit" value="Network RO PDF" onclick="javascript:NetworkRO(<?php echo $order_id ?>,'<?php echo $network_name; ?>')" target="_blank" /></td>
        </tr>
        <tr>
            <th>A</th>
            <th>B</th>
            <th>C</th>
            <th>D</th>
            <th>E</th>
            <th>F</th>
            <th>G</th>
            <th>H</th>
            <th>&nbsp;</th>
        </tr>
        <tr>

            <td><?php echo $c['b'] . "/" . $c['a'] ?></td>
            <td><?php echo $c['c'] ?></td>
            <td><?php echo $c['d'] ?></td>                          
            <td><?php print date('d-M-Y', strtotime($c['e'])) ?></td>
            <td><?php print date('d-M-Y', strtotime($c['f'])) ?></td>
            <td><?php echo $c['g'] ?></td>
            <td><?php echo $c['h'] ?></td>
            <td><?php echo $c['g'] * $c['h'] ?>
            <td><a href=javascript:add_price(<?php echo $order_id ?>,'<?php echo $channel_str; ?>')>Add Price</a> </td>
        </tr>


        <?php
    } else {
        $channel_str .= $c['a'] . '~' . str_replace('/', 'surero', $c['b']) . '~' . $c['c'] . '~' . str_replace(' ', 'surero', $c['d']) . '~' . date('d-M-Y', strtotime($c['e'])) . '~' . date('d-M-Y', strtotime($c['f'])) . '~' . $c['g'] . '~' . $c['h'] . '~' . str_replace('@', 'surero', $c['i']) . '~' . str_replace(' ', 'surero', $c['j']) . '~' . $c['k'];
        ?>
            <tr>
                <td><?php echo $c['b'] . "/" . $c['a'] ?></td>
                <td><?php echo $c['c'] ?></td>
                <td><?php echo $c['d'] ?></td>                          
                <td><?php print date('d-M-Y', strtotime($c['e'])) ?></td>
                <td><?php print date('d-M-Y', strtotime($c['f'])) ?></td>
                <td><?php echo $c['g'] ?></td>
                <td><?php echo $c['h'] ?></td>
                <td><?php echo $c['g'] * $c['h'] ?>
                <td><a href=javascript:add_price(<?php echo $order_id ?>,'<?php echo $channel_str; ?>')>Add Price</a> </td>
            </tr>
        <?php
    }
}
?>
</table>
于 2012-10-16T10:42:34.027 に答える