Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP][MYSQL]Dzielenie na kolumny
-Tomek67-
post
Post #1





Goście







Posiadam funkcje listowania artykułów w swoim portalu i przedstawia się ona następująco
  1. <?php
  2. function list_arts($topic, $limit, $page) {
  3.  
  4. global $art_tbl, $PHP_SELF, $arts, $art_sort, $uart_sort;
  5.  
  6. if($uart_sort=='') $sort = $art_sort; else $sort = $uart_sort;
  7.  
  8.  
  9. echo '<br><div align="center" class="uni_01">sortuj według: <b>tytułu</b> <a title="alfabetycznie" href="articles.php?topic='.$topic.'&sortby=title-ASC"><img src="images/s_down.gif" border="0" align="absmiddle"></a><a
  10. href="articles.php?topic='.$topic.'&sortby=title-DESC"><img src="images/s_up.gif" border="0" align="absmiddle"></a>
  11. | <b>daty</b> <a title="najstarsze u góry" href="articles.php?topic='.$topic.'&sortby=date-ASC"><img src="images/s_down.gif" border="0" align="absmiddle"></a><a
  12. href="articles.php?topic='.$topic.'&sortby=date-DESC"><img src="images/s_up.gif" border="0" align="absmiddle"></a>
  13. | <b>popularności</b> <a title="najpopularniejsze u góry" href="articles.php?topic='.$topic.'&sortby=opened-DESC"><img src="images/s_down.gif" border="0" align="absmiddle"></a><a
  14. href="articles.php?topic='.$topic.'&sortby=opened-ASC"><img src="images/s_up.gif" border="0" align="absmiddle"></a>
  15. <br><br>
  16. <tr><td>';
  17.  
  18. $query = "SELECT * FROM $art_tbl WHERE topic='$topic' ORDER BY $sort";
  19. $result = mysql_query($query);
  20. $ile = mysql_num_rows($result);
  21.  
  22. if($ile<>0) {
  23. $znk = $page * $limit;
  24. mysql_data_seek($result, $znk);
  25. }
  26.  
  27. $aaa = 0;
  28. while($r = mysql_fetch_array($result)) {
  29.  
  30. $id = $r['id'];
  31. $title = $r['title'];
  32. $text = $r['discript'];
  33. $date = $r['date'];
  34. $author = $r['author'];
  35. $comment_num = $r['comments'];
  36. $opened = $r['opened'];
  37.  
  38. $text = stripslashes($text);
  39. $title = stripslashes($title);
  40.  
  41.  
  42. $title = '<a href="articles.php?id='.$id.'" title="dodany: '.$date.'" class="t_art">'.$title.'</a></b>';
  43. $print = 'print.php?what=article&id='.$id;
  44. $more = 'articles.php?id='.$id;
  45.  
  46. if(is_login()=='yes') {
  47. $link_a = '<a href="admin.php?op=art&cmd=edit&id='.$id.'&goto='.basename($PHP_SELF).'" title="edit" class="t_art">E</a>';
  48. $link_b = '<a href="admin.php?op=art&cmd=del&id='.$id.'&goto='.basename($PHP_SELF).'" title="delete" class="t_art">D</a>';
  49. $title = $title.' <b>ˇˇˇ</b> (<b> '.$link_a.'</b> | <b>'.$link_b.' </b>)';
  50. }
  51.  
  52. $comment = 'comment.php?what=article&id='.$id;
  53.  
  54. art_theme($title, $text, $author, $date, $comment, $comment_num, $print, $more, $opened);
  55.  
  56. $aaa++;
  57. if($aaa==$limit) break;
  58.  
  59. }
  60.  
  61. $ile = mysql_num_rows($result);
  62. if($ile<>0) {
  63. $arts= $ile;
  64. $ile = $ile / $limit;
  65. $ile = ceil($ile);
  66.  
  67. $bbb = 0;
  68. while($bbb<>$ile) {
  69.  
  70. $ccc = $bbb + 1;
  71. if($page==$bbb) {
  72. $re = $re.'[<b>'.$ccc.'</b>] ';
  73. } else {
  74. $re = $re.'[<a href="'.$PHP_SELF.'?page='.$bbb.'&topic='.$topic.'">'.$ccc.'</a>] ';
  75. }
  76.  
  77. $bbb++;
  78. }
  79. } else {
  80. $re = $re.'[<b>1</b>] ';
  81. }
  82. $arts = (int) $arts;
  83. return $re;
  84. }
  85. ?>


korzysta ona przy wyświetlaniu z funkcji themsa
  1. <?php
  2. function art_theme($title, $text, $poster, $date, $comment, $comment_num, $print, $more, $opened)
  3. {
  4.    global $color;
  5.  
  6.    $more = '<a href="'.$more.'"><font class="title">zagraj</font></a><br>';
  7.  
  8.    echo '
  9.    
  10.    <font class="title"><center><b>'.$title.'</b></center></font>
  11.    
  12.    <center><img src="'.$text.'" width="120" height="120"></center>
  13.    ';
  14.  
  15.    if($mod<>'err')
  16.    {
  17.        echo '
  18.        <center><font class="title">grano: '.$opened.' | '.$more.'</font></center><br>
  19.        ';
  20.    }
  21.  
  22.    echo '
  23.    
  24.    
  25.    
  26.    ';
  27.  
  28. }
  29. ?>


i tutaj nasuwa sie problem bo chce wyświetlić wyniki w 3 kolumnach
czyli w taki sposób
|x1| |x4| |x7|
|x2| |x5| |x8|
|x3| |x6| |x9|

może też być w taki
|x1| |x4| |x7|
|x2| |x5| |x8|
|x3| |x6| |x9|

ale żeby było w 3 kolumnach
czyli żeby po trzech wywołaniach funkcji art_theme te 3 wyniki zostawiło w jednej kolumnie a następne wyświetlały sie w następnej kolumnie
ktoś mi podpowiedział że takie dzielenie można uzyskać za pomocą funkcji
  1. <?php
  2. echo '<table><tr>';
  3. $x=0;
  4. while($r= wyniki z bazy){
  5. if($x++ % liczba kolumn == 1)echo '</tr><tr>';
  6. echo '<td>wynik</td>';
  7. }
  8. echo '</tr></table>'
  9. ?>

ale nie mam pojęcia jak to dostosować... prosze o pomoc
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
-Tomek67-
post
Post #2





Goście







a może mi ktoś podpowiedzieć jak to dostosować do powyższych funkcji... bo sobie nie daje rady
Go to the top of the page
+Quote Post
StevDefs
post
Post #3





Grupa: Zarejestrowani
Postów: 51
Pomógł: 0
Dołączył: 22.08.2019

Ostrzeżenie: (10%)
X----


Lasting Longer In Bed Exercises Priligy Prix Prednisone Without Prescription viagra Venta De Cialis Generico En Espana Buy Synthroid From Mexico Buy Propecia In Canada

Viagra Pro Generic viagra Best Deals.On Viagra

Venta Cialis Generico Espana Cialis In Pune viagra Amoxicillin Clavulanate Rash Expired Amoxicillin Pills

Cheapeast Amoxicilina Medication No Physician Approval generic levitra 20mg Generic Levitra Free Shipping Acheter Du Amoxil Generique Ventolin With Viagra
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 13.10.2025 - 23:23