Jump to content
  • 0

Вивод td и tr


meta.ua
 Share

Question

Есть код:


<?php if ($option['type'] == 'image') { ?>
<div id="option-<?php echo $option['product_option_id']; ?>" class="option">
<?php if ($option['required']) { ?>
<span class="required">*</span>
<?php } ?>
<b><?php echo $option['name']; ?>:</b><br />
<table class="option-image">
<?php foreach ($option['option_value'] as $option_value) { ?>
<tr>
<td style="width: 1px;"><input type="radio" name="option[<?php echo $option['product_option_id']; ?>]" value="<?php echo $option_value['product_option_value_id']; ?>" id="option-value-<?php echo $option_value['product_option_value_id']; ?>" /></td>
<td><label for="option-value-<?php echo $option_value['product_option_value_id']; ?>"><img src="<?php echo $option_value['image']; ?>" alt="<?php echo $option_value['name'] . ($option_value['price'] ? ' ' . $option_value['price_prefix'] . $option_value['price'] : ''); ?>" /></label></td>
<td><label for="option-value-<?php echo $option_value['product_option_value_id']; ?>"><?php echo $option_value['name']; ?>
<?php if ($option_value['price']) { ?>
(<?php echo $option_value['price_prefix']; ?><?php echo $option_value['price']; ?>)
<?php } ?>
</label></td>
</tr>
<?php } ?>
</table>
</div>

Оно виводит в столбец картинки и инфу некую про них, но все идут в столбец (изза того что каждий елемент в td)

Помогите переделать что б 3 елементи виводились в одном td, следующие 3 в другом td.

Что б сделать 3 картинки в строке. Очень срочно)) Помогите пожалуйста. Вся загвоздка в цикле))

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

делал как-то давно, что типо такого

$counter = 1; $newtr = false;
if (!(mysql_num_rows($result ) == 0)):
while($data = mysql_fetch_array($result )):
if ($newtr):
print "<tr>"; $newtr = false;
endif;
print "<td>";
print "данные";
print "</td>";
if ($counter == 3):
print "</tr>"; $newtr = true; $counter = 1; continue;
endif;
$counter++;
endwhile;
endif;

его конечно оптимизировать можно, но вполне работоспособный :boast:

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. See more about our Guidelines and Privacy Policy