Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php][css] Problem z wyswietlaniem danych z sql
mefjiu
post 14.06.2007, 02:35:18
Post #1





Grupa: Zarejestrowani
Postów: 313
Pomógł: 5
Dołączył: 22.03.2005

Ostrzeżenie: (0%)
-----


Witam tworze sobie katalog stron opartych o skrypt qlweb z modyfikacją by jaho
Problem polega na tym że ten katalog był przystosowany do tabel a chciałbym go przerobić na css
głównie problem mam z kategoriami głównymi

chciałbym aby wyglądały one tak


a udało mi sie zrobić tak


siedzę nad tym już 2 dzień i kompletnie nie wiem jak to zrobić
Podzielone jest to na 2 div'y lewy i prawy
i pierwsze 4 kategorie są ok a potem wszystko całą resztę wsadza do prawego
poprawny kod css powinien wyglądac tak
  1.                        <div class="left_side">
  2.                              <p><b><img src="images/arrow.gif" alt=">" /><a class="title" href="#">Arts</a></b><br />
  3.                              <a href="#">Music</a>, <a href="#">Television</a>, <a href="#">Movies</a>...</p>
  4.                              <p><b><img src="images/arrow.gif" alt=">" /><a class="title" href="#">Computers</a></b><br />
  5.                              <a href="#">Internet</a>, <a href="#">Software</a>, <a href="#">Hardware</a>...</p>
  6.                              <p><b><img src="images/arrow.gif" alt=">" /><a class="title" href="#">Shopping</a></b><br />
  7.                              <a href="#">Autos</a>, <a href="#">Clothing</a>, <a href="#">Gifts</a>...</p>
  8.                        </div>                  
  9.                        <div class="right_side">
  10.                              <p><b><img src="images/arrow.gif" alt=">" /><a class="title" href="#">Business</a></b><br />
  11.                              <a href="#">Jobs</a>, <a href="#">Real Estate</a>, <a href="#">Investing</a>...</p>
  12.                              <p><b><img src="images/arrow.gif" alt=">" /><a class="title" href="#">Health</a></b><br />
  13.                              <a href="#">Fitness</a>, <a href="#">Medicine</a>, <a href="#">Alternative</a>...</p>
  14.                              <p><b><img src="images/arrow.gif" alt=">" /><a class="title" href="#">Sports</a></b><br />
  15.                              <a href="#">Baseball</a>, <a href="#">Basketball</a>, <a href="#">Soccer</a>...</p>
  16.                        </div>



W kodzie żródłowym strony wygląda tak:
  1.                  
  2. <div class="left_side"><p><b><img src="images/arrow.gif" alt=">" /><a class="title" href="index.php?kat=4" >34534</a></b><br />
  3. <a  href="index.php?kat=4&amp;pod=28">3f34</a>,
  4. <a  href="index.php?kat=4&amp;pod=27">4rsdf</a>,
  5. <a  href="index.php?kat=4&amp;pod=29">234rsdf</a>,
  6. <p><b><img src="images/arrow.gif" alt=">" /><a class="title" href="index.php?kat=3" >3453453</a></b><br />
  7. <a  href="index.php?kat=3&amp;pod=39">3f34</a>,
  8. <a  href="index.php?kat=3&amp;pod=36">32sdf</a>,
  9.  
  10. <a  href="index.php?kat=3&amp;pod=43">4r434rsrfs</a>,
  11. </div><div class=right_side>
  12. <p><b><img src="images/arrow.gif" alt=">" /><a class="title" href="index.php?kat=5" >345345564543</a></b><br />
  13. <a  href="index.php?kat=5&amp;pod=54">4r434rsrfs</a>,
  14. <a  href="index.php?kat=5&amp;pod=53">32sf</a>,
  15. <a  href="index.php?kat=5&amp;pod=49">4rsdf</a>,
  16. <p><b><img src="images/arrow.gif" alt=">" /><a class="title" href="index.php?kat=2" >Katalogi stron</a></b><br />
  17. <a  href="index.php?kat=2&amp;pod=7">dupka</a>,
  18. <a  href="index.php?kat=2&amp;pod=8">jeżyk</a>,
  19.  
  20. <a  href="index.php?kat=2&amp;pod=12">34rsdf</a>,
  21. </div><div class=right_side>
  22. <p><b><img src="images/arrow.gif" alt=">" /><a class="title" href="index.php?kat=10" >kategoria1</a></b><br />
  23. <p><b><img src="images/arrow.gif" alt=">" /><a class="title" href="index.php?kat=9" >kategoria1</a></b><br />
  24. </div><div class=right_side>
  25. <p><b><img src="images/arrow.gif" alt=">" /><a class="title" href="index.php?kat=8" >kategoria1</a></b><br />
  26. <p><b><img src="images/arrow.gif" alt=">" /><a class="title" href="index.php?kat=6" >kategoria1</a></b><br />
  27. </div><div class=right_side>
  28. <p><b><img src="images/arrow.gif" alt=">" /><a class="title" href="index.php?kat=7" >kategoria2</a></b><br />
  29. <p><b><img src="images/arrow.gif" alt=">" /><a class="title" href="index.php?kat=1" >Rozrywka</a></b><br />
  30.  
  31. <a  href="index.php?kat=1&amp;pod=16">dupka</a>,
  32. <a  href="index.php?kat=1&amp;pod=3">Kawały</a>,
  33. <a  href="index.php?kat=1&amp;pod=20">#$dff</a>,
  34. </div>



Natomiast kod php jest taki:
  1. <?
  2. $bck_file = 'glowna.bck';
  3. if ($g_use_bck and $USE->get_bck($bck_file) ) {
  4. } else {
  5. ?>
  6. <?php
  7.  $plik = $g_szablon .'/menu.tpl.php';
  8.  $szablon_kategori = $USE->get_template($plik); 
  9.  
  10.  $ilosc_kolumn_kategorii = 2;
  11.  $class_table = 'cat_block_home';
  12.  $class_td = 'in_link_home_cat_div';
  13.  $class_link_pod = 'in_link_home_sub';
  14.  $class_link_kategoria = 'in_link_home_kat';
  15.  
  16.  
  17.  $width = round(100 / $ilosc_kolumn_kategorii,2);
  18.  $j = 0;
  19.  $w_in = 0;
  20.  
  21.  $pyt = "SELECT id_kat,kategoria FROM `" . $g_przedrostek . "kategorie` where `akt`= '0' ORDER BY kategoria";
  22.  $odp = $DB->query ($pyt);
  23.  
  24.  if (file_exists($g_szablon.'/button.gif')  ) 
  25. $obrazek = '<img src="' . $g_szablon.'/button.gif" alt=""> ';
  26.  else {
  27. $obrazek = '';
  28.  }
  29.  
  30.  if ($odp) {
  31. $adresy = '';
  32.  
  33. while($kat = mysql_fetch_array ($odp)) {
  34. $kategoria = $kat['kategoria'];
  35. $id_kat = $kat['id_kat'];
  36.  
  37. if ($w_in == $ilosc_kolumn_kategorii) {
  38.  $adresy .= "</div><div class=right_side>";
  39.  $adresy .= "rn";
  40.  $w_in = 0;
  41. }
  42.  
  43. /// 
  44.  
  45.  
  46. $adresy .= $obrazek;
  47. if ($mod_rewrite) {
  48. $nazwa=strtolower(filtr_znaki($kategoria,','));
  49.  
  50. $adresy .= '<p><b><img src="images/arrow.gif" alt=">" /><a class="title" href="'.$nazwa.'-'. $mod_kategoria . '-' . $id_kat . '.html" >' . $kategoria . '</a></b><br />';
  51. $adresy .= "rn";
  52. } else {
  53.  $adresy .= '<p><b><img src="images/arrow.gif" alt=">" /><a class="title" href="index.php?kat=' . $id_kat . '" >' . $kategoria . '</a></b><br />';
  54. $adresy .= "rn";
  55. }
  56.  
  57. $max_znakow_pod = 40;
  58. $max_znakow_podx= 24;
  59. $pyt = "SELECT id_kat,podkategoria,id_pod FROM `" . $g_przedrostek . "podkategorie` WHERE `id_kat` = $id_kat and `akt`=0 ORDER BY RAND() LIMIT 0,3";
  60. $podkat = $DB->query ($pyt);
  61. $i = 0;
  62. $len = 0;
  63. if ($podkat) {
  64. while(($pod = mysql_fetch_array ($podkat)) && $i<12) {
  65.  $x = $kat['id_kat'];
  66.  $y = $pod['id_pod'];
  67.  $z = $pod['podkategoria'];
  68.  $len_p=strlen($z);
  69.  if ($len_p < $max_znakow_podx) {
  70.  $len += $len_p;
  71.  if ($len > $max_znakow_pod) {
  72. break;
  73.  }
  74. if ($mod_rewrite) {
  75.  $nazwa=strtolower(filtr_znaki($z,','));
  76.  $adresy .= '<a href="'.$nazwa.'-' .$x .',' .$mod_podkat . ',' . $y . '.html">' . $z . '</a>, ';
  77. $adresy .= "rn";
  78. } else {
  79.  $adresy .= '<a href="index.php?kat=' .$x . '&amp;pod=' .$y . '">' . $z . '</a>, '; 
  80. $adresy .= "rn";
  81. }
  82. $i++; }
  83. }
  84.  
  85. }
  86.  
  87.  
  88. $w_in++;
  89.  
  90. }
  91.  
  92. for ($i=$w_in; $i <$ilosc_kolumn_kategorii; $i++) {
  93. $adresy .= "rn";
  94. }
  95.  
  96. $gora = '<div class="left_side">';
  97. $dol = '</div>';
  98. $menu_tpl = $gora . $adresy . $dol;
  99. if ($g_sugeruj_kategorie) {
  100. $sugeruj='<a class="in_link" href="index.php?i=1">'.$l_suggest_cat.'</a>';
  101. } else { $sugeruj='';}
  102. $szablon_kategori = str_replace('{sugeruj_kategorie}', $sugeruj, $szablon_kategori);
  103. $szablon_kategori = str_replace('{menu_kategorii}', $menu_tpl, $szablon_kategori);
  104.  
  105. echo $szablon_kategori;
  106.  
  107.  
  108.  }
  109. ?>
  110.  
  111. <?
  112. if ($g_use_bck) { $USE->make_bck($bck_file, $szablon_kategori); }
  113. } ?>



Będę naprawę wdzięczny jak ktoś mi z tym pomoże.
Już z góry dziękuję za wszelką pomoc, oraz za zapoznanie się z moim problemem.

Serdecznie pozdrawiam mefjiu
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 4)
Darti
post 14.06.2007, 09:56:35
Post #2





Grupa: Zarejestrowani
Postów: 1 076
Pomógł: 62
Dołączył: 6.03.2005
Skąd: Wroc

Ostrzeżenie: (0%)
-----


Zauważ, że tam są tylko dwa bloki <div>.
Może zrób to w ten sposób, że zawartość bloków wpisuj sobie do tabeli adresy (adresy[0] dla lewej strony a adresy[1] dla prawej), o tym do którego bloku wpisywać w danym momencie decyduj za pomocą dzielenia modulo przez 2 inkrementowanej zmiennej (u Ciebie tą rolę spełnia $w_in, tylko że teraz ją resetujesz co 2 przebiegi, a nie powinieneś).
Po skończeniu górnej pętli While (dla kategorii) możesz dopisać odpowiednie divy do komórek tabeli adresy, przypisać komórki do zmiennej $menu_tpl i masz gotowe smile.gif


--------------------
The answer is out there, Neo. It's looking for you. And it will find you, if you want it to.
SERVER_SOFTWARE : Apache/2.2.4 (Win32) PHP/5.2.1
MySQL Client API version : 5.0.27
Go to the top of the page
+Quote Post
mefjiu
post 14.06.2007, 11:46:52
Post #3





Grupa: Zarejestrowani
Postów: 313
Pomógł: 5
Dołączył: 22.03.2005

Ostrzeżenie: (0%)
-----


Troszkę to zbyt skomplikowane jak dla mnie sad.gif w sumie wiem dokładnie i ładnie jest opisane jak to zrobić, ale chyba brakuje mi brakuje takich umiejętności.

czy mogę prosić aby ktoś mi to chcoiarz abym miał jakieś rzutowanie.
Go to the top of the page
+Quote Post
Darti
post 14.06.2007, 12:25:24
Post #4





Grupa: Zarejestrowani
Postów: 1 076
Pomógł: 62
Dołączył: 6.03.2005
Skąd: Wroc

Ostrzeżenie: (0%)
-----


Proszzzz :

  1. <?php
  2. $bck_file = 'glowna.bck';
  3. if ($g_use_bck and $USE->get_bck($bck_file) ) {
  4. } else {
  5. $plik = $g_szablon .'/menu.tpl.php';
  6. $szablon_kategori = $USE->get_template($plik);
  7.  
  8. $ilosc_kolumn_kategorii = 2;
  9. $class_table = 'cat_block_home';
  10. $class_td = 'in_link_home_cat_div';
  11. $class_link_pod = 'in_link_home_sub';
  12. $class_link_kategoria = 'in_link_home_kat';
  13.  
  14.  
  15. $width = round(100 / $ilosc_kolumn_kategorii,2);
  16. $j = 0;
  17. $w_in = 0;
  18.  
  19. $pyt = "SELECT id_kat,kategoria FROM `" . $g_przedrostek . "kategorie` where `akt`= '0' ORDER BY kategoria";
  20. $odp = $DB->query ($pyt);
  21.  
  22. if (file_exists($g_szablon.'/button.gif')  )
  23. $obrazek = '<img src="' . $g_szablon.'/button.gif" alt=""> ';
  24. else {
  25. $obrazek = '';
  26. }
  27.  
  28. if ($odp) {
  29. $adresy = array('','');
  30. $max_znakow_pod = 40;
  31. $max_znakow_podx= 24;
  32.  
  33. while($kat = mysql_fetch_array ($odp)) {
  34. $kategoria = $kat['kategoria'];
  35. $id_kat = $kat['id_kat'];
  36.  
  37. $strona = $w_in % 2; // ustawiam strone lewa lub prawa
  38.  
  39. $adresy[$strona] .= $obrazek;
  40. if ($mod_rewrite) {
  41. $nazwa=strtolower(filtr_znaki($kategoria,','));
  42.  
  43. $adresy[$strona] .= '<p><b><img src="images/arrow.gif" alt=">" /><a class="title" href="'.$nazwa.'-'. $mod_kategoria . '-' . $id_kat . '.html" >' . $kategoria . '</a></b><br />';
  44. $adresy[$strona] .= "rn";
  45. } else {
  46. $adresy[$strona] .= '<p><b><img src="images/arrow.gif" alt=">" /><a class="title" href="index.php?kat=' . $id_kat . '" >' . $kategoria . '</a></b><br />';
  47. $adresy[$strona] .= "rn";
  48. }
  49.  
  50.  
  51. $pyt = "SELECT id_kat,podkategoria,id_pod FROM `" . $g_przedrostek . "podkategorie` WHERE `id_kat` = $id_kat and `akt`=0 ORDER BY RAND() LIMIT 0,3";
  52. $podkat = $DB->query ($pyt);
  53. $i = 0;
  54. $len = 0;
  55. if ($podkat) {
  56. while(($pod = mysql_fetch_array ($podkat)) && $i<12) {
  57. $x = $kat['id_kat'];
  58. $y = $pod['id_pod'];
  59. $z = $pod['podkategoria'];
  60. $len_p=strlen($z);
  61. if ($len_p < $max_znakow_podx) {
  62. $len += $len_p;
  63. if ($len > $max_znakow_pod) {
  64. break;
  65. }
  66. if ($mod_rewrite) {
  67. $nazwa=strtolower(filtr_znaki($z,','));
  68. $adresy[$strona] .= '<a href="'.$nazwa.'-' .$x .',' .$mod_podkat . ',' . $y . '.html">' . $z . '</a>, ';
  69. $adresy[$strona] .= "rn";
  70. } else {
  71. $adresy[$strona] .= '<a href="index.php?kat=' .$x . '&amp;pod=' .$y . '">' . $z . '</a>, ';
  72. $adresy[$strona] .= "rn";
  73. }
  74. $i++; }
  75. }
  76.  
  77. }
  78. $w_in++;
  79. }
  80.  
  81. $left_side = '<div class="left_side">';
  82. $right_side = '<div class=right_side>';
  83. $end_of_side = '</div>';
  84. $menu_tpl = $left_side . $adresy[0] . $end_of_side . $right_side . $adresy[1] . $end_of_side; // zlepienie stron w jeden ciag
  85. if ($g_sugeruj_kategorie) {
  86. $sugeruj='<a class="in_link" href="index.php?i=1">'.$l_suggest_cat.'</a>';
  87. } else { $sugeruj='';}
  88. $szablon_kategori = str_replace('{sugeruj_kategorie}', $sugeruj, $szablon_kategori);
  89. $szablon_kategori = str_replace('{menu_kategorii}', $menu_tpl, $szablon_kategori);
  90.  
  91. echo $szablon_kategori;
  92.  
  93.  
  94. }
  95. if ($g_use_bck) { $USE->make_bck($bck_file, $szablon_kategori); }
  96. }
  97. ?>


--------------------
The answer is out there, Neo. It's looking for you. And it will find you, if you want it to.
SERVER_SOFTWARE : Apache/2.2.4 (Win32) PHP/5.2.1
MySQL Client API version : 5.0.27
Go to the top of the page
+Quote Post
mefjiu
post 15.06.2007, 21:23:40
Post #5





Grupa: Zarejestrowani
Postów: 313
Pomógł: 5
Dołączył: 22.03.2005

Ostrzeżenie: (0%)
-----


O kurde działa blink.gif DZIĘKUJĘ ci pięknie Darti

darti :-)
mam teras taki sam problem :-)

tylko że ze z wyświetlaniem czego innego ale dokładnie ma być ta sama zasada :-)
Przepraszam że cię tak męczę :-)
ale mam sposób aby ci się odwdzięczyć. Jak skończę tą stronkę to się do Ciebie odezwę. :-) Narazie nic nie mogę zdradzić

  1. <?php
  2. function getBreadcrumb(&$output, $categoryId) {
  3. global $TBL, $INDEX_PAGE, $ODGet;
  4.  
  5. if($categoryId <= 0) {
  6. $output = '<a href="'.$INDEX_PAGE.'">Main</a>';
  7. return;
  8. }
  9.  
  10. $qry = "SELECT id, name, parent_id FROM {$TBL['category']} WHERE id = $categoryId";
  11. $rsl = mysql_query($qry);
  12. $row = mysql_fetch_assoc($rsl);
  13.  
  14. $url = $INDEX_PAGE.'?p='.$ODGet['p'].'&cat='.$row['id'];
  15.  
  16. if(trim($output) == '')
  17. $output = '<a href="'.$url.'">'.$row['name'].'</a>';
  18. else
  19. $output = '<a href="'.$url.'">'.$row['name'].'</a>' . ' ť ' . $output;
  20.  
  21. //- still have parents?
  22. if($row['parent_id'] != 0) {
  23. getBreadcrumb($output, $row['parent_id']);
  24. } else {
  25. $output = '<a href="'.$INDEX_PAGE.'">Main</a> ť '.$output;
  26. }
  27. }
  28. ?>
Go to the top of the page
+Quote Post

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

 



RSS Wersja Lo-Fi Aktualny czas: 20.07.2025 - 02:06