I have built an html table display like the one shown below. I would like to costruct a nXn matric table where the selected radio/value from each row is plugged into each row of the matrix. All the values below the diagonal will be the opposite of the values above on the top of the matrix. User can select 9 if he prefers the first elem1 extremely more compared with the elem2, OR 1/9 for the opposite case and 1 if they have equal relevance.
This is what my html table looks like and the matrix table i would like to derive out of it
My problem really isn't understanding how it should should work but translating into code. If there is a way to loop through the first set of block in the table i.e. 1-4 and plug each result into a matrix row. If i do the same for the rest then i can have my complete matrix table. I have tried serializeArray() on the table so far but really stuck. I need your advise please.
Here is the code I have for generating my html table:
for ($i=0; $i < (sizeOf ($myArray)); $i++){ //loop through the whole table body
$currentObs = $myArray[$i]['ObstacleDescription']; //set pointer to my current obstacle value
$x = 0;
for ($j=$i+1; $j <= (sizeOf($myArray))-1; $j++){ //loop through the inner table
$next = $myArray[$j]['ObstacleDescription'];
$or = " or ";
if (!($currentObs == $next)){
?>
<tr id="<?php echo $myArray[$i]['ComplianceID']; ?>">
<td valign='center'> <?php echo $x+1; ?> </td>
<?php $x++; ?>
<td>
<?php echo
"<input type='radio' name='op[$j]' value='0' class='myradio'>"." ".$currentObs
?>
</td>
<td><?php echo
$or." "."<input type='radio' name='op[$j]' value='1' class='myradio'>"." ".$next;
?>
</td>
<td><small>
<?php echo " 1 "."<input type='radio' name='Intense[$j]' value='1' class='myradio'>"; ?>
</small></td>
<td><small>
<?php echo
" 2 "."<input type='radio' name='Intense[$j]' value='2' class='myradio'>".
" 3 "."<input type='radio' name='Intense[$j]' value='3' class='myradio'>".
" 4 "."<input type='radio' name='Intense[$j]' value='4' class='myradio'>".
" 5 "."<input type='radio' name='Intense[$j]' value='5' class='myradio'>".
" 6 "."<input type='radio' name='Intense[$j]' value='6' class='myradio'>".
" 7 "."<input type='radio' name='Intense[$j]' value='7' class='myradio'>".
" 8 "."<input type='radio' name='Intense[$j]' value='8' class='myradio'>".
" 9 "."<input type='radio' name='Intense[$j]' value='9' class='myradio'>";
?>
</small></td>
<?php }
}
echo "<tr><td colspan='5'><hr style='border:0; height:0px' /></td></tr>";
echo "<tr><td colspan='5'><hr style='border:0; height:0px' /></td></tr>";
}
echo "</tr>";
?>
If anymore details is needed, please let me know. thanks
This is what my html table looks like and the matrix table i would like to derive out of it
My problem really isn't understanding how it should should work but translating into code. If there is a way to loop through the first set of block in the table i.e. 1-4 and plug each result into a matrix row. If i do the same for the rest then i can have my complete matrix table. I have tried serializeArray() on the table so far but really stuck. I need your advise please.
Here is the code I have for generating my html table:
for ($i=0; $i < (sizeOf ($myArray)); $i++){ //loop through the whole table body
$currentObs = $myArray[$i]['ObstacleDescription']; //set pointer to my current obstacle value
$x = 0;
for ($j=$i+1; $j <= (sizeOf($myArray))-1; $j++){ //loop through the inner table
$next = $myArray[$j]['ObstacleDescription'];
$or = " or ";
if (!($currentObs == $next)){
?>
<tr id="<?php echo $myArray[$i]['ComplianceID']; ?>">
<td valign='center'> <?php echo $x+1; ?> </td>
<?php $x++; ?>
<td>
<?php echo
"<input type='radio' name='op[$j]' value='0' class='myradio'>"." ".$currentObs
?>
</td>
<td><?php echo
$or." "."<input type='radio' name='op[$j]' value='1' class='myradio'>"." ".$next;
?>
</td>
<td><small>
<?php echo " 1 "."<input type='radio' name='Intense[$j]' value='1' class='myradio'>"; ?>
</small></td>
<td><small>
<?php echo
" 2 "."<input type='radio' name='Intense[$j]' value='2' class='myradio'>".
" 3 "."<input type='radio' name='Intense[$j]' value='3' class='myradio'>".
" 4 "."<input type='radio' name='Intense[$j]' value='4' class='myradio'>".
" 5 "."<input type='radio' name='Intense[$j]' value='5' class='myradio'>".
" 6 "."<input type='radio' name='Intense[$j]' value='6' class='myradio'>".
" 7 "."<input type='radio' name='Intense[$j]' value='7' class='myradio'>".
" 8 "."<input type='radio' name='Intense[$j]' value='8' class='myradio'>".
" 9 "."<input type='radio' name='Intense[$j]' value='9' class='myradio'>";
?>
</small></td>
<?php }
}
echo "<tr><td colspan='5'><hr style='border:0; height:0px' /></td></tr>";
echo "<tr><td colspan='5'><hr style='border:0; height:0px' /></td></tr>";
}
echo "</tr>";
?>
If anymore details is needed, please let me know. thanks
Comment