SkyD Posted June 19, 2005 Report Share Posted June 19, 2005 Sveiki! Man ir txt fails kuraa iekshaa ir vairaakas rindinjas, teiksim: aabols apelsiins banaans cukurs sviests .. Taatad, man vajag taa, izvadot sho txt failu lapaa, lai iekraasojas katra rindinja savaa kraasaa, piem paara rindinjas zaljaa, nepaara zilaa.. Kaa to izdariit?? Link to comment Share on other sites More sharing options...
bubu Posted June 19, 2005 Report Share Posted June 19, 2005 Tieši tā kā tu teici - pārbaudi vai rindiņa ir pāra, tad krāso zaļu, ja nē, tad zilu. Kas tur nesaprotams? Pats sev tak atbildi pateici $f = file('fails.txt'); $i = 0; foreach($f as $rinda) { echo '<p style="color: ' . ($i ? 'green' : 'blue') . '">'.trim($rinda).'</p>'; $i = ($i+1)&1; } Link to comment Share on other sites More sharing options...
SkyD Posted June 19, 2005 Author Report Share Posted June 19, 2005 mjaa... es nepareizi iisteniibaa izteicos.. mana vaina.. Man vajag, lai taas rindinjas iekraasojas tabulaa.. Vareetu jau taa: <table> <tr class="nepara"><td>...</td></tr> <tr class="para"><td>...</td></tr> <tr class="nepara"><td>...</td></tr> <tr ... utt ...</tr> </table> ..bet man nav noteikts skaits ar rindinjaam.. Link to comment Share on other sites More sharing options...
bubu Posted June 19, 2005 Report Share Posted June 19, 2005 Nu un kāda atšķirība? Aizvieto <p> ar <tr> i viss čiki būs. Link to comment Share on other sites More sharing options...
SkyD Posted June 19, 2005 Author Report Share Posted June 19, 2005 nu taa jau izdariju, bet vinjsh neiet vienalga.. <table style="width: 15%;"> <? $f = file('fails.txt'); $i = 0; foreach($f as $rinda) { echo '<tr style="color: ' . ($i ? 'gray' : 'red') . '">'.trim($rinda).'</tr>'; $i = ($i+1)&1; } ?> </table> Link to comment Share on other sites More sharing options...
v3rb0 Posted June 19, 2005 Report Share Posted June 19, 2005 (edited) echo '<tr><td style="color: ' . ($i ? 'gray' : 'red') . '">'.trim($rinda).'</td></tr>'; Edited June 19, 2005 by v3rb0 Link to comment Share on other sites More sharing options...
SkyD Posted June 19, 2005 Author Report Share Posted June 19, 2005 Tag viss shtokos.. bet plz pasakat kapeec man neiet shitas kods?? style.php <? session_start(); $style = $_GET['style']; switch($style) { case 1: $_SESSION['style'] = 1; break; case 2: $_SESSION['style'] = sarkans; break; } ?> index.php <link rel="stylesheet" href="styles/'.$SESSION['style'].'1.css" type="text/css"> Link to comment Share on other sites More sharing options...
v3rb0 Posted June 19, 2005 Report Share Posted June 19, 2005 <link rel="stylesheet" href="styles/'.$SESSION['style'].'.css" type="text/css"> `1` novac :] Link to comment Share on other sites More sharing options...
bubu Posted June 19, 2005 Report Share Posted June 19, 2005 (edited) Tur iespējams ir domāts, kautgan neviens jau nezin kā tev vajag, lai pateiktu kāpēc nestrādā: <link rel="stylesheet" href="styles/style.php?style='.$SESSION['style'].'" type="text/css"> Edited June 19, 2005 by bubu Link to comment Share on other sites More sharing options...
Aleksandrs Posted June 19, 2005 Report Share Posted June 19, 2005 (edited) Tur iespējams ir domāts, kautgan neviens jau nezin kā tev vajag, lai pateiktu kāpēc nestrādā:<link rel="stylesheet" href="styles/style.php?style='.$SESSION['style'].'" type="text/css"> 18647[/snapback] Nav gadijumā: <link rel="stylesheet" href="styles/style.php?style='.$_SESSION['style'].'" type="text/css"> ? UN style.php <? session_start(); $style = $_GET['style']; switch($style) { case 1: $_SESSION['style'] = 1; break; case 2: $_SESSION['style'] = sarkans; break; } ?> Nav gadijumā: $_SESSION['style'] = 'sarkans'; ? Edited June 19, 2005 by Aleksandrs Link to comment Share on other sites More sharing options...
SkyD Posted June 19, 2005 Author Report Share Posted June 19, 2005 Tagad ir shitaa, bet vienalga neiet: style.php <? $style = $_GET['style']; switch($style) { case '1': $style = 'styles/1.css'; setcookie("1", $style, time()+3600); break; case '2': $style = 'styles/2.css'; setcookie("2", $style, time()+3600); break; } ?> <a href="?style=1">Stils 1</a> <a href="?style=2">Stils 2</a><br> index.php <link rel="stylesheet" href="styles/'.echo $_COOKIE['$style'].'.css" type="text/css"> Kas vareetu buut par kljuudu, plz notesteejiet uz sevim, ja zinat kur kljuuda tad izlabojiet.. =] Link to comment Share on other sites More sharing options...
Kavacky Posted June 19, 2005 Report Share Posted June 19, 2005 Darīt nav mums ko, kā testēt te sevīm? Ja jau tev nestrādā, tad paskaties, kādu kļūdu uzrāda. Izlasi. Noskaidro, ko tas nozīmē. Izlabo. Link to comment Share on other sites More sharing options...
bubu Posted June 19, 2005 Report Share Posted June 19, 2005 Kas vareetu buut par kljuudu, plz notesteejiet uz sevim, ja zinat kur kljuuda tad izlabojiet.. =] Tu zini kas ir kļūda? Kļūda ir tad, kad kautkas neiet kā vajag. Pasaki mums, kā lai mēs zinām, kā ir jābūt? Kā lai izlabo kļūdu, ja nezin kā vajag strādāt? Link to comment Share on other sites More sharing options...
v3rb0 Posted June 19, 2005 Report Share Posted June 19, 2005 nu kā var nezināt - vajag lai engine strādā!! (sorr par spamu, nenocietos:) ) Link to comment Share on other sites More sharing options...
SkyD Posted June 20, 2005 Author Report Share Posted June 20, 2005 a kaadam nav kaads vienkaarsh style skripts?? Vajag, taa: ja izveelas STILS 1, lai uzstaada kaa default 1.css, ja izveelas STILS 2, lai uzstaada kaa default 2.css .. PLZ kaads uzstaisat.. Link to comment Share on other sites More sharing options...
Recommended Posts