I have six columns of output. The content is grabbed from an array (created as a php array and then sent as a js array). An sample line of that comprises the array $set is as follows:
$set[] = array('q'=>'墨水','qurl'=>'001','a1'=>'o','a2'=>'ui','f'=>'m','m'=>'4sh','e'=>'3');
Lets say I have four rows of content. My code currently generates this:
Col 1 Col 2 Col 3 Col 4 Col 5 Col 6
Col 1 Col 2 Col 3 Col 4 Col 5 Col 6
Col 1 Col 2 Col 3 Col 4 Col 5 Col 6
Col 1 Col 2 Col 3 Col 4 Col 5 Col 6
I need to put these four rows into two primary sets of columns. So like this:
Col 1 Col 2 Col 3 Col 4 Col 5 Col 6 Col 7 Col 8 Col 9 Col 10 Col 11 Col 12
Col 1 Col 2 Col 3 Col 4 Col 5 Col 6 Col 7 Col 8 Col 9 Col 10 Col 11 Col 12
What is an efficient way of doing this? My current code looks like this:
…
$js_array = json_encode($set);
…
<table>
<?php $counter = 0;
while ($counter < 20) :
$item = $set[$counter]?>
<tr class="q<?php echo $counter; ?>">
<form>
<td><h5><?php echo $counter+1; ?></h5></td>
<td><a class="question" href="javascript:soundManager.play('<?php echo $item['qurl'] ?>','audio/part2/type3/type3_<?php echo $item['qurl'] ?>.mp3');"><?php echo $item['q'] ?></a></td>
<td><?php echo $item['f'] ?></td>
<td><input class="a1" type="text" name="a1" maxlength="4" size="2" /></td>
<td><?php echo $item['m'] ?> <input class="a2" type="text" name="a2" maxlength="4" size="2" /><?php echo $item['e'] ?></td>
<td><input class="submit submit-<?php echo $counter; ?>" type="submit" value="Submit" /></td></form>
</tr>
<?php $counter++; ?>
<?php endwhile; ?>
</table>
You can do it as follows: