Jee Posted March 24, 2005 Report Share 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. Link to comment Share on other sites More sharing options...
bubu Posted March 24, 2005 Report Share 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) Link to comment Share on other sites More sharing options...
Jee Posted March 24, 2005 Author Report Share Posted March 24, 2005 Laikam nepateicu visu! Katra rindinja tiek izvikta no mysql. Kaaa tas ir hackers.lv forumaa. Link to comment Share on other sites More sharing options...
bubu Posted March 24, 2005 Report Share 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); Link to comment Share on other sites More sharing options...
Jee Posted March 25, 2005 Author Report Share Posted March 25, 2005 Man nestraadaa! Link to comment Share on other sites More sharing options...
Kavacky Posted March 25, 2005 Report Share Posted March 25, 2005 Kas nestrādā? Link to comment Share on other sites More sharing options...
Jee Posted March 25, 2005 Author Report Share Posted March 25, 2005 Rindas neiekraasojas! Link to comment Share on other sites More sharing options...
Kavacky Posted March 25, 2005 Report Share 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? Link to comment Share on other sites More sharing options...
Jee Posted March 25, 2005 Author Report Share 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. Link to comment Share on other sites More sharing options...
hmnc Posted March 25, 2005 Report Share 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 Link to comment Share on other sites More sharing options...
Kavacky Posted March 25, 2005 Report Share 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ā? Link to comment Share on other sites More sharing options...
Jee Posted March 25, 2005 Author Report Share Posted March 25, 2005 Paldies viss straada tagad! Link to comment Share on other sites More sharing options...
bubu Posted March 25, 2005 Report Share 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'); Link to comment Share on other sites More sharing options...
Osiris Posted March 26, 2005 Report Share Posted March 26, 2005 Tiešām, bērnudārzs... Link to comment Share on other sites More sharing options...
Jee Posted March 26, 2005 Author Report Share Posted March 26, 2005 Ko juus te muldat? Mans skriptelis bija ljo liidziigs Kavacky skriptam, bet kautkaa nesanaaca. :angry: Link to comment Share on other sites More sharing options...
Recommended Posts