Ich habe ein neues Array zu einem vorhandenen Array hinzugefügt, aber das Layout ist gebrochen.Layout-Problem nach dem Hinzufügen eines neuen Arrays zu Tabelle
Der Code zur Ausgabe der Reihe ist:
for ($i=1; $i<=$comp_value_count; $i++) {
$compPro = 'pro'.$i;
$attrCount = $result[$compPro][11];//A count of how many options there are per product
$compDescription .= '<td>' . $result[$compPro][2] . '</td>';
$compModel .= '<td>' . $result[$compPro][3] . '</td>';
$compWeight .= '<td>' . $result[$compPro][4] . '</td>';
$compQuantity .= '<td>' . $result[$compPro][5] . '</td>';
$compManufacturer .= '<td>' . $result[$compPro][7] . '</td>';
$compattr1 .= '<td>';
for ($c=0; $c<=$attrCount; $c++){
$compattr2 .= $result[$compPro][8][$c] . $result[$compPro][9][$c] . "\n";
}
$compattr3 .= '</td>';
}
// create the display
echo '<tr class="rowEven"><th>' . COMPARE_QUANTITY . '</th>' . $compQuantity . '</tr>';
echo '<tr class="rowOdd"> <th>' . COMPARE_MODEL . '</th>' . $compModel . '</tr>';
echo '<tr class="rowEven"><th>' . COMPARE_WEIGHT . '</th>' . $compWeight . '</tr>';
echo '<tr class="rowOdd"> <th>' . COMPARE_MANUFACTURER . '</th>' . $compManufacturer . '</tr>';
echo '<tr class="rowEven"><th>' . COMPARE_DESC . '</th>' . $compDescription . '</tr>';
echo '<tr class="rowOdd"> <th>' . COMPARE_OPTNAME . '</th>' . $compattr1 . $compattr2 . $compattr3 . '</tr>';
echo '</table>';
}
Eine Geige zeigt das Layout dieser Code erzeugt ist https://jsfiddle.net/uzmk61v7/2/
Und noch zeigen, was wollte ich es wie hier zu sehen ist https://jsfiddle.net/85wztu3z/1/
var_dump ($ result) Ausgabe ist unter
array(2) {
["pro1"]=> array(12) {
[0]=> string(191) "01 button stainless steel audio panel - surface"
[1]=> string(612) "01 button stainless steel audio panel - surface"
[2]=> string(144) "5101S - 1 button audio door entry phone intercom panel SRS surface mounted, vandal resistant 1 way traditional audio, BS316 stainless steel,..."
[3]=> string(5) "5101S"
[4]=> string(1) "0"
[5]=> string(1) "1"
[6]=> string(171) "£147.74 Inc VAT £123.12 Ex VAT"
[7]=> string(3) "SRS"
[8]=> array(4) {
[0]=> string(12) "Call Buttons"
[1]=> string(8) "Mounting"
[2]=> string(6) "Finish"
[3]=> string(5) "Range"
}
[9]=> array(4) {
[0]=> string(20) "1 call button"
[1]=> string(20) "Surface mount"
[2]=> string(35) "Stainless Steel VR (brushed)"
[3]=> string(15) "SRS 5000"
}
[10]=> string(73) "remove"
[11]=> string(1) "4"
}
["pro2"]=> array(12) {
[0]=> string(200) "00 way VR brass video panel, size D"
[1]=> string(576) "00 way VR brass video panel, size D"
[2]=> string(148) "6600 - 0 button video door entry phone intercom panel Size D SRS vandal resistant 0 way traditional video, polished brass, engravable, door entry..."
[3]=> string(4) "6600"
[4]=> string(1) "0"
[5]=> string(1) "0"
[6]=> string(171) "£155.95 Inc VAT £129.96 Ex VAT"
[7]=> string(3) "SRS"
[8]=> array(4) {
[0]=> string(8) "Mounting"
[1]=> string(6) "Finish"
[2]=> string(5) "Range"
[3]=> string(7) "Cabling"
}
[9]=> array(4) {
[0]=> string(18) "Flush mount"
[1]=> string(21) "Polished brass"
[2]=> string(15) "SRS 4000"
[3]=> string(34) "SRS Video C + 6 + n cabling"
}
[10]=> string(73) "remove" [11]=> string(1) "4"
}
}
Irgendwelche Vorschläge, wie ich das beheben kann?
So öffnen HTML erzeugt und sehen, was falsch ist. –
Können Sie das 'var_dump ($ result)' Ergebnis anzeigen? –
@u_mulder kann ich sehen, was falsch ist, kann einfach nicht einen Fix herauszufinden Es
mehr Inhalt