2016-03-24 2 views
0

My HTML-Code nicht gesetzt ist:Wie kann ich die für und foreach Schleifenwert in php

<table cellpadding="0" cellspacing="0" border="1" class="pro_code_table"> 
    <tr> 
     <th colspan="12" class="pro_code_lable_with_data">Product Code Detailes</th> 
    </tr> 
    <tr> 
     <td class="table_val_data">Title</td> 
    @foreach($x as $k_x => $v_x) 
     <td class="table_val_data">{{ $v_x }}</td> 
    @endforeach 
    </tr> 
    <tr> 
    @foreach ($y as $k_y => $v_y) 
     <td class="table_val_data">{{ $v_y }}</td> 
    <?php $pro_code_count=count($pro_code); 
    //print_r($pro_code); 
    ?> 
    @for($r = 1; $r <=sizeof($x); $r++) 
     <td> 
     <?php $i=1; ?> 
     @foreach($pro_code as $key=>$val) 
     @if($i % 2 != 0) 
      <input type="text" name="pro_code[]" value="{{ $val }}"> 
     @else 
      <input type="text" name="pro_code[]" value="{{ $val }}"> 
     @endif 
     @endforeach 
     <?php 
     $i++; 
     ?> 
     </td> 
     @endfor 
    </tr> 
    @endforeach 
</table> 

dass i kann im Inneren Tabelle Schleifendaten, die X- und Y-Achse geschlungen korrekt, aber innerhalb eines <td> Daten sind geschleift mehr als eine Zeit, zu stoppen

nw wie kann ich den Looping-Prozess

mein o \ p wie schaut unten

enter image description here

Ich möchte Daten wie ein unten wie die

enter image description here

+0

hallo Bjoern, hw u kann meine Frage bearbeiten – KarnaGowtham

Antwort

0
<table cellpadding="0" cellspacing="0" border="1" class="pro_code_table"> 
<tr> 
<th colspan="12" class="pro_code_lable_with_data">Product Code Detailes</th> 
</tr> 
<tr> 
<td class="table_val_data">Title</td> 
@foreach($x as $k_x => $v_x) 
<td class="table_val_data">{{ $v_x }}</td> 
@endforeach    
</tr> 

<tr> 
@foreach($y as $k_y_t=> $v_y_t) 
<td class="table_val_data">{{ $v_y_t }}</td> 

@foreach($y as $k_y=> $v_y) 
    @foreach($x as $k_x => $v_x) 
    @if($k_y_t==$k_y) 
     <td class="table_val_data"> 
    @foreach($pro_code as $k_pro_code=> $v_pro_code)    
    <?php 
    if($k_x.'-'.$k_y==$k_pro_code){ 
     echo '<input type="text" name="value" value="'.$v_pro_code.'">'; 
    }     
    ?> 
    @endforeach    
    </td> 
    @endif  
    @endforeach 
@endforeach 
</tr> 

@endforeach 
</table> 

$x: {"3":"bule","4":"green"} 
$y: {"5":"cotten","6":"polyester"} 
$pro_code_in_edit: {"3-5":"12","4-5":"23","3-6":"56","4-6":"89"} 

enter image description here