Jee Posted March 24, 2005 Report Posted March 24, 2005 Nevaru nekaadi izdomaat kaa to uztaisiit. Piemeeram man ir tabula, man vajag, lai katra rinda ir savaa kraasaa. Lai katra otraa rinda vienaadaa kraasaa.
bubu Posted March 24, 2005 Report Posted March 24, 2005 Tiešām kautko šādu nevari izdomāt: <table> <tr class="rinda1"> <td>dati</td><td>dati</td> </tr> <tr class="rinda2"> <td>dati</td><td>dati</td> </tr> <tr class="rinda1"> <td>dati</td><td>dati</td> </tr> <tr class="rinda2"> <td>dati</td><td>dati</td> </tr> </table> (protams CSSā nodefinē .rinda1 un .rinda2 klases ar atšķirīgām krāsām)
Jee Posted March 24, 2005 Author Report Posted March 24, 2005 Laikam nepateicu visu! Katra rindinja tiek izvikta no mysql. Kaaa tas ir hackers.lv forumaa.
bubu Posted March 24, 2005 Report Posted March 24, 2005 Un ko tas maina lietas būtībā? $res = mysql_query("..."); $i = 0; while ($row = mysql_fetch_row($res)) { echo '<tr class="rinda'.strval($i+1).'"><td>'; echo implode('</td><td>', $row); echo '</td></tr>'; $i = ($i+1)%2; } mysql_free_result($res);
Kavacky Posted March 25, 2005 Report Posted March 25, 2005 A man sienas nekrāsojas! Ko tu tur esi sarakstījis? Vai rāda kādu kļūdu vai vienkārši nekrāsojas?
Jee Posted March 25, 2005 Author Report Posted March 25, 2005 $query="SELECT * FROM `raksti`ORDER BY ID DESC"; $res = mysql_query("$query"); $i = 0; while ($row = mysql_fetch_row($res)) { echo '<tr class="rinda'.strval($i+1).'"><td>'; echo implode('</td><br><td>', $row); echo '</td></tr>'; $i = ($i+1)%2; } mysql_free_result($res); Arii css uztaisiiju klasi rinda un nekaa! Vienkaarshi nekraasojas.
hmnc Posted March 25, 2005 Report Posted March 25, 2005 (edited) nu bāc. bērnudārzs. kā nekrāsojas? paskaties html source - parādās klases pareizi? nu vienai rindai viena klase, otrai otra? neparādās? tad meklē kļūdu php skriptos. parādās tomēr? tad meklē kļūdu CSS. Edited March 25, 2005 by hmnc
Kavacky Posted March 25, 2005 Report Posted March 25, 2005 <table> <?php $alldata = mysql_query("SELECT * FROM taabele ORDER BY id ASC"); $col = 0; while ( $row = mysql_fetch_array($alldata) ) { $col++; if ( $col % 2 == 0 ) { $color = 'FFFFEE'; } else { $color = 'EEFFFF'; } echo '<tr bgcolor="#'.$color.'"><td align="left">'.$row['taskotevvajag'].'</td></tr>'; } ?> </table> Vai šādi strādā?
bubu Posted March 25, 2005 Report Posted March 25, 2005 Šitādus ifus: if ( $col % 2 == 0 ) { $color = 'FFFFEE'; } else { $color = 'EEFFFF'; } var smuki optimizēt: $color = ($col%2 ? 'EEFFFF' : 'FFFFEE');
Jee Posted March 26, 2005 Author Report Posted March 26, 2005 Ko juus te muldat? Mans skriptelis bija ljo liidziigs Kavacky skriptam, bet kautkaa nesanaaca. :angry:
Recommended Posts