Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [PHP][MYSQL]wyświetlanie treści w 2 kolumnach
Forum PHP.pl > Forum > Przedszkole
trzykas
Witam serdecznie mam taki problem.
Modyfikuje mój skrypt z kawałami i chciałem zmienić wygląd aby kawały były wyświetlanie jak na stronie www.wcipy.pl w 2 kolumnach
Myślałem nad tym żeby po dublować zmienne $res itp ale to nie wyjdzie, myślałem również aby zrobić div'a który za pomocą css wyświetlał by się w 2 kolumnach ale niestety to chyba jest nie wykonalne.
Strona wygląda tak:
  1. <?
  2. $res = mysql_query('select * from `stuff` where `category`=' . ((int) $_GET['cat']));
  3.  
  4. $row = mysql_fetch_assoc($res);
  5.  
  6. if(isset($categories[$row['category']]))
  7.            $cat = sprintf("%s", $categories[$row['category']]);
  8.        else
  9.            $cat = (string) '';
  10.  
  11. echo' <html>
  12. <title>'.$site_www2.' - kawały - '.$cat.'</title>
  13. </html>';
  14.  
  15.  
  16. <table  width="100% cellpadding="0" cellspacing="0" class="brd">
  17.        <tr><td class="m2">kawały - '.$cat.'</td></tr>
  18.        <tr><td width="100%"><div class="newsy">';
  19.  
  20. ?>
  21. <?php
  22.  
  23. if(isset($_GET['typ'])) {
  24.  $typ = '`typ` = ' . (int) $_GET['typ'];
  25. }else{
  26.  $typ = "((`typ` >= 1 and `typ` <= 4) or (typ = '15') or (typ = '16') or (typ = '17'))";
  27. }
  28.  
  29. //$typ = (isset($_GET['typ']) ? '`typ` = ' . (int) $_GET['typ']&nbsp: '((`typ` >= 1 and `typ` <= 4) or (typ = '15'))');
  30. $cat = (isset($_GET['cat']) ? ' and `category` = ' . (int) $_GET['cat']&nbsp: '');
  31. $order = '';
  32. if ($_GET['top'] == 1)
  33. {
  34.  $order = ' order by `ocena` desc';
  35. }
  36. elseif ($_GET['last'] == 1)
  37. {
  38.  $order = ' order by `added` desc';
  39. }
  40.  
  41. $res = mysql_query('select * from `stuff` where ' . $typ . $cat);
  42. // ilosć trafień
  43. $hits = mysql_num_rows($res);
  44.  
  45. $res = mysql_query('select * from `stuff` where ' . $typ . $cat . $order . ' order by added desc limit ' . ((int) $_GET['currentpage'] * 10) . ', ' . ((int) $_GET['currentpage'] * 10 + 10));
  46.  
  47.  
  48.  
  49. if ($hits == 0)
  50. {
  51.  echo 'Nie ma żadnych rekordów w tej kategorii.';
  52. }
  53. else
  54. {
  55.  while ($row = mysql_fetch_assoc($res))
  56.                
  57.  {
  58.        if($row['added']>0)
  59.            $date = sprintf('%s / %s', date('Y.m.d', $row['added']), date('::s', $row['added']));
  60.        else
  61.            $date = (string) '';
  62.        $comments_count = (int) 0;
  63.        $query = sprintf("SELECT COUNT(*) AS CommentsCount FROM komentarze WHERE stuff='%d'", $row['id']);
  64.        $comments = mysql_query($query);
  65.        if($comments) {
  66.            $record = mysql_fetch_assoc($comments);
  67.            $comments_count = $record['CommentsCount'];
  68.            mysql_free_result($comments);
  69.        }
  70.        
  71.        if(isset($categories[$row['category']]))
  72.            $cat = sprintf("%: ", $categories[$row['category']]);
  73.        else
  74.            $cat = (string) '';
  75.        printf('<p class="linki"align="left"><b>'.$count.'Dowcipy - '.$cat.' </b><br>
  76.  ' . $row['opis'] . '</font>
  77.  <center>
  78. </p>
  79. <p align="center"> <b>Autor: </b> ' . $row['login'] . '<b>  Ocen: </b> ' . $row['ocena'] . '<b> </b></b><br>
  80.  [<font size="2"><a href="index.php?page=display&id=' . $row['id'] . '">więcej...</a></font>]<hr>',
  81.                $cat, $row['id'], $row['tytul'],
  82.            $date,
  83.                        
  84.                        
  85.  
  86.                      
  87.            $row['ocena'], $row['counter'],
  88.            $comments_count, $row['login']);
  89.            if ($licznik == $liczba_kolumn - 1){
  90.  
  91. include'reklama2.php';
  92. echo'<hr>';
  93.   }
  94.  $licznik++;
  95.  $licznik %= $liczba_kolumn;
  96.    }
  97. }
  98.  
  99. echo '<div style="text-alig: center">';
  100.  
  101. /********* NUMEROWANIE *********/
  102.  
  103. $temp = min((int) $_GET['currentpage'] + 4, ceil((float) $hits / 9.0));
  104.  
  105. for ($i = max((int) $_GET['currentpage'] - 4, 0); $i < $temp; $i++)
  106. {
  107.   print("<a href=\"index.php?page=list&currentpage=" . $i . "&cat=" . $_GET['cat'] . "\"><font size=2>" . ($i+1) . " | </font></a>");
  108.   if($i == ($temp - 1)) {
  109.        print("<a href=\"index.php?page=list&currentpage=" . ($temp - 1) . "&cat=" . $_GET['cat'] . "\"><img src=\"gfx/dalej.jpg\" border=\"0\"></a>");
  110.   }
  111. }
  112. /*******************************/
  113.  
  114. echo '</div>';
  115. ?>


czy mógłby mi ktoś doradzić naprowadzić.
Method
naprowadzam smile.gif
http://www.webmasterworld.com/php/3479199.htm
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.