我试图将css类应用于php中的动态行。但是它没有发生。这是我的代码
请有人建议我我要去哪里错了。我已经为行声明了一个计数器,但是没有在哪里增加其计数。
<table width='100%' border='0' cellspacing='0' cellpadding='2'>
<tr>
<td class='tddash'>10 latest unpaid customer invoices</td>
</tr>
<tr>
<td valign='top'>";
$SQL = "SELECT salesorders.orderno,
debtorsmaster.name,
custbranch.brname,
salesorders.customerref,
salesorders.orddate,
salesorders.deliverydate,
salesorders.deliverto,
salesorders.printedpackingslip,
salesorders.poplaced,
SUM(salesorderdetails.unitprice*salesorderdetails.quantity*(1-salesorderdetails.discountpercent)/currencies.rate) AS ordervalue
FROM salesorders INNER JOIN salesorderdetails
ON salesorders.orderno = salesorderdetails.orderno
INNER JOIN debtorsmaster
ON salesorders.debtorno = debtorsmaster.debtorno
INNER JOIN custbranch
ON debtorsmaster.debtorno = custbranch.debtorno
AND salesorders.branchcode = custbranch.branchcode
INNER JOIN currencies
ON debtorsmaster.currcode = currencies.currabrev
WHERE salesorderdetails.completed=0
GROUP BY salesorders.orderno,
debtorsmaster.name,
custbranch.brname,
salesorders.customerref,
salesorders.orddate,
salesorders.deliverydate,
salesorders.deliverto,
salesorders.printedpackingslip,
salesorders.poplaced
ORDER BY salesorders.orderno";
$SalesOrdersResult1 = DB_query($SQL,$db);
echo "<table width='100%' celpadding='2' class='selection'><tbody>";
$TableHeader = "<tr><th> Customer </th><th>Order Date</th><th>Delivery Date</th><th>Delivery To</th><th>Order Total</th></tr> ";
$k = 0;
while ($row = DB_fetch_array($SalesOrdersResult1))
{
if ($k == 1){
echo '<tr class="EvenTableRows">';
$k = 0;
} else {
echo '<tr class="OddTableRows">';
$k = 1;
}
$FormatedOrderValue1 = locale_number_format($row['ordervalue'],$row['currdecimalplaces']);
//$TotalOrderValue = $array_sum($FormatedOrderValue1);
//$FormatedOrderValue1 = locale_number_format($myrow['ordervalue'],$_SESSION['CompanyRecord']['decimalplaces']);
$FormatedOrderDate = ConvertSQLDate($row['orddate']);
$FormatedDelDate = ConvertSQLDate($row['deliverydate']);
echo " <td> " . $row['name'] . " </td>";
echo " <td>$FormatedOrderDate</td><td>$FormatedDelDate</td><td> " . $row['deliverto'] . " </td><td>$FormatedOrderValue1</td> ";
}
//echo "<tr><td colspan='3'>Total</td><td colspan='2'>$TotalOrderValue</td></tr></tbody>";
//echo $array_sum($FormatedOrderValue1);
echo "</table>";
echo"</td>
</tr>
</table>
最佳答案
尝试将其放入while循环中。
if ($k == 1){
echo '<tr class="EvenTableRows">';
$k = 0;
} else {
echo '<tr class="OddTableRows">';
$k = 1;
}
关于php - 将样式表类应用于动态行,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/15803674/