/    Sign up×
Community /Pin to ProfileBookmark

add css code inside while loop <tr>

hi…

I have query to display data and I use while loop.

here is my code:

[code]
echo “<table id=’kanban_list’>”;
echo “<tr>
<th><label>Display Details:</label><input onclick=’showDetails(this);’ id=’chkDetail’ type=’checkbox’ checked=’checked’ value=’wip’/></th>
<th> PCODE </th>
<th> LOT CODE </th>
<th> CHEMICAL WEIGHING </th>
<th> COMPOUNDING </th>
<th> EXTRUSION </th>
<th> FORMING </th>
<th> DEFLASHING </th>
<th> KANBAN </th>
<th> VIRTUAL </th>
<th> TOTAL </th>
<!–<th> MIN LOT </th>–>
</tr>”;
$sql = “SELECT DISTINCT kd.PCODE, kc.count_wip_chemical_weighing, kc.count_wip_compounding, kc.count_wip_extrusion,
kc.count_wip_forming, kc.count_wip_deflashing, kc.kanban, kc.virtual, kc.total FROM kanban_checker kc JOIN kanban_data kd ON kc.PCODE = kd.PCODE
ORDER BY kc.PCODE”;
$result = mysql_query($sql, $con);
while($row = mysql_fetch_assoc($result)){
echo “<tr>
<td>Total Lot ID (Lot)</td>
<td>&nbsp;$row[PCODE]</td>
<td>&nbsp;</td>
<td>&nbsp;$row[count_wip_chemical_weighing]</td>
<td>&nbsp;$row[count_wip_compounding]</td>
<td>&nbsp;$row[count_wip_extrusion]</td>
<td>&nbsp;$row[count_wip_forming]</td>
<td>&nbsp;$row[count_wip_deflashing]</td>
<td>&nbsp;$row[kanban]</td>
<td>&nbsp;$row[virtual]</td>
<td>&nbsp;$row[total]</td>
<!– <td>&nbsp;$row[min_lot]</td> –>
</tr>”;
}

$sql = “SELECT DISTINCT kd.PCODE, kdc.count_doz_chemical_weighing, kdc.count_doz_compounding, kdc.count_doz_extrusion,
kdc.count_doz_forming, kdc.count_doz_deflashing, kdc.kanban_doz, kdc.virtual_doz, kdc.total_doz FROM kanban_checker_doz kdc JOIN kanban_data kd ON kdc.PCODE = kd.PCODE
WHERE kd.PCODE = ‘$row[PCODE]’
ORDER BY kdc.PCODE”;
$result_qty = mysql_query($sql, $con);

while ($row_doz = mysql_fetch_assoc($result_qty)){
echo “<tr>
<td>Total Qty (Doz)</td>
<!–<td>&nbsp;</td> –>
<td>&nbsp;$row_doz[PCODE]</td>
<td>&nbsp;</td>
<td>&nbsp;$row_doz[count_doz_chemical_weighing]</td>
<td>&nbsp;$row_doz[count_doz_compounding]</td>
<td>&nbsp;$row_doz[count_doz_extrusion]</td>
<td>&nbsp;$row_doz[count_doz_forming]</td>
<td>&nbsp;$row_doz[count_doz_deflashing]</td>
<td>&nbsp;$row_doz[kanban_doz]</td>
<td>&nbsp;$row_doz[virtual_doz]</td>
<td>&nbsp;$row_doz[total_doz]</td>
<!– <td>&nbsp;$row[min_lot]</td> –>
</tr>”;
}
echo “</table>”;
[/code]

sample data:

Display Details—Compound—Chemical Weighing—–etc…
———————P28————1.00—————————-
———————P28————250.00————————
———————P30————2.00————————–
———————P30————520.00———————
———————P32————1.00—————————-

I need to add alternate background color per compound.
for example:

P28 green
P30 yellow
P32 green
P33 yellow
and so on.

Any help is highly appreciated.

Thank you

———————P32————520.00———————–
———————P33————4.00—————————-
———————P33————1000.00———————

to post a comment
CSS

0Be the first to comment 😎

×

Success!

Help @newphpcoder spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...