I have a while loop which calls data from a db and displays it within a table.
However, the table is stretching too far across my page.
So I did a test with a second while loop so that if $i < 6 then a new row is added.
However when I nested one loop inside the other my WAMP, unsuprisingly, hated this and never loaded the page.
So I replaced the nested while loop with for loop instead.
This does then change the table however, it also repeats everything in the table 7 times instead of just the once.
[code=php]echo ‘<table border=”1″>
<tr>’;
$query = “select image from wp_wpsc_variation_values where variation_id = ‘1’”;
$result = mysql_query($query);
while($row = mysql_fetch_array($result)) {
for($i = 1; $i < 8; $i++){
if($i == 7) {
echo “<tr>”;
}
echo ‘<td>
<input type=”radio” value=”<?php echo wpsc_the_variation_id(); ?>” class=”wpsc_select_variation” name=”variation[<?php echo wpsc_vargrp_id(); ?>]” id=”<?php echo wpsc_vargrp_form_id(); ?>”></td>’;
echo “<td><img src=’http://www.site.co.uk/wordpress/wp-content/plugins/wp-e-commerce/themes/lsotheme/variationimgs/$row[image]’ /></td>”;
if($i == 7) {
echo “</tr>”;
}
}
}
echo ‘</tr>
</table>’;
Thats the code I’m using, so each picture is now displaying 7 times where I want it to display once. But each set of 7 pictures are displaying correctly.
[URL=”http://i972.photobucket.com/albums/ae207/Aravona/3.png”]http://i972.photobucket.com/albums/ae207/Aravona/3.png
That shows what I mean a bit better.
Any help would be wonderful.
Regards,
Aravona