[英]line-breaks between every 2 row
I'm quit new with mysql, and php but everytime i'm learning. 我用mysql和php退出,但是每次我都在学习。 For a friend of my I'm building a website with a small pricing-list on it.
对于我的一个朋友,我正在建立一个网站,上面有一个小的定价清单。 The prices are from a database, but I now want to create a empty line bewtween the 2nd and the 3th line, but I don't know how to do that.
价格来自数据库,但是我现在想在第二行和第三行之间创建一条空行,但是我不知道该怎么做。
I use the following code to receive the information from the database; 我使用以下代码从数据库接收信息;
<table id="nails" class="prijzen">
<thead>
<tr>
<th>Nails</th>
<th>Price first visite</th>
<th>Regular price</th>
</tr>
</thead>
<?php
// while ($row = $queryNails->fetch_assoc()) {
$i = 0;
while ($row = $regularNails->fetch_assoc())
{
if($i%3 == 0)
{
echo "<tr class='even'>";
echo "<td>" . $row['name'] ."</td>";
echo "<td>" . $row['prijs'] ."</td>";
echo "<td>" . $row['actie_prijs'] ."</td>";
echo "</tr>";
}
else
{
echo "<tr>";
echo "<td>" . $row['name'] ."</td>";
echo "<td>" . $row['prijs'] ."</td>";
echo "<td>" . $row['actie_prijs'] ."</td>";
echo "</tr>";
}
$i++;
?>
<tbody>
<?php
}
?>
</tbody>
</table>
<br>
I now have every odd-line a styling, but that is not something I like. 现在,我的每条奇数行都有样式,但这不是我喜欢的。 I would like to create a sort of group of the output.
我想创建一组输出。
Hope someone can help me with that. 希望有人可以帮助我。 If more information is needed, please let me know.
如果需要更多信息,请告诉我。
Please stop suggestion to enter a <br />
in between lines. 请停止建议
<br />
之间输入<br />
。 That's not gonna work at all, tables-101: Everything not placed in a td
will be placed in before the table. table-101:这根本行不通,所有未放入
td
都将放置在表格之前。 So all you get is a bunch of empty lines before the whole table. 因此,您得到的只是整个表格之前的一堆空行。
The code is allready there (if you want it before every 3rd row: 该代码是有媒体链接(如果你每 3行之前想要的:
if($i%3 == 0)
{
// The code right here will only run when $i / 3 is exactly 0 (3,6,9,etc)
echo '<tr><td colspan="3">Blank line</td></tr>';
echo "<tr class='even'>";
echo "<td>" . $row['name'] ."</td>";
echo "<td>" . $row['prijs'] ."</td>";
echo "<td>" . $row['actie_prijs'] ."</td>";
echo "</tr>";
}
If you only want it once before the 3rd row, make this the first code in your while: 如果你只在第3行之前想一次 ,使这个在你同时第一码:
if($i==3){ echo '<tr><td colspan="3">Blank line</td></tr>'; }
The %
is modulus. %
是模量。 It gives you how much is left after getting the max amount of whole divisions: 它使您获得最大的整数除法后还剩下多少:
echo 1 %3 = 1;
echo 2 %3 = 2;
echo 3 %3 = 0; // exactly dividable by 3
echo 4 %3 = 1;
echo 5 %3 = 2;
echo 6 %3 = 0; // exactly dividable by 3
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.