Chickenz Posted January 13, 2005 Report Share Posted January 13, 2005 Man taads jautaajums, kaa lai zinjas tiek izdrukaatas 2x2 tabulaa??? Negribas divus ciklus likt... ir kaadi padomi, kaa vareetu ar vienu ciklu no db atlasiit 4 ieraxtus un samest 2x2 tabulaa??? ps. raxtiiju shito topicu tikai tapeec ka vecajam news neviens nepieveersh uzmaniibu... Link to comment Share on other sites More sharing options...
Kaklz Posted January 13, 2005 Report Share Posted January 13, 2005 Padomā par kaut ko līdzīgu šim: $news = array('news1' , 'news2', ' news3' , 'news4'); $newsId = 0; echo '<table><tr>'; foreach ($news as $newsItem){ echo '<td>' . $newsItem . '</td>'; if ($newsId % 2 == 0 && $newsId < count($news) - 1){ echo '</tr><tr>'; } } if ($newsId % 2 != 0){ echo '<td> </td>'; } echo '</tr></table>'; Link to comment Share on other sites More sharing options...
bubu Posted January 13, 2005 Report Share Posted January 13, 2005 (edited) Nu bāc! <?php $res = mysql_query('SELECT teksts FROM news LIMIT 4'); $rows = array(); while ($temp = mysql_fetch_row($res)) { $rows = $temp[0]; } while (count($rows)<4) { $rows[] = ""; } echo '<table>'; echo '<tr><td>'.$rows[0].'</td><td>'.$rows[1].'</td></tr>'; echo '<tr><td>'.$rows[2].'</td><td>'.$rows[3].'</td></tr>'; echo '</table>'; ?> Kaklz pasteidzās :) Edited January 13, 2005 by bubu Link to comment Share on other sites More sharing options...
Venom Posted January 13, 2005 Report Share Posted January 13, 2005 NB: bubu $rows[] = $temp[0]; ziņas, kas izvadās Z veidā $pahorizontali=2; echo '<table><tr>'; $tmp=0; while($res=mysql_fetch_array(...)) { echo '<td>'.$res['news'].'</td>'; if (++$tmp%$pahorizontali=0) echo '</tr><tr>'; } echo '</tr></table>'; ziņas izvadās И veidā: $pavertikali=2; echo '<div style="float:left">'; $tmp=0; while($res=mysql_fetch_array(...)) { echo '<div class="newsblock">'.$res['news'].'</div>'; if (++$tmp%$paveritkali=0) echo '</div><div style="float:left">'; } echo '</div>'; Link to comment Share on other sites More sharing options...
Chickenz Posted January 13, 2005 Author Report Share Posted January 13, 2005 Man saprotamaakais likaas bubu variants... meegjinaashu taa dariit... TNX!!! Link to comment Share on other sites More sharing options...
Venom Posted January 14, 2005 Report Share Posted January 14, 2005 a kas tur nesaprotams - pirmajā variantā pēc n kolonnām sākam jaunu rindu, otrajā - pēc n rindām sākam jaunu divu, kas ar css būs pielikts pa labi no iepriekšējā Link to comment Share on other sites More sharing options...
Recommended Posts