Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [Smarty][MySQL][PHP] Rysowanie tabelki (krzyżowej?)
kasior
post
Post #1





Grupa: Zarejestrowani
Postów: 78
Pomógł: 0
Dołączył: 20.12.2005
Skąd: Bydgoszcz

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


Pomózcie proszę, bo juz sie zakręciłem zupełnie. Mam dane, ale z rysowaniem tego juz problem.
Ale po kolei. Są dwie tabele: drivers i graph. W pierwszej sa kierowcy, w drugiej sa zapisywane dane ich statusów w poszczególnym tygodniu (np "w aucie")

Wygląda to tak:

(IMG:http://peterwebs.pl/tabela.jpg)

Jedynki sa wpisane tylko na razie,zeby coś było widać.

Najpierw wyciągam z bazy dane:

  1. $sql= 'select * from drivers where active = "1"';
  2. $stmt = $hDB->prepare($sql);
  3. $stmt->execute();
  4. $num = $stmt->rowCount();
  5.  
  6.  
  7. if ($num>0){
  8. $art = $stmt->setFetchMode(PDO::FETCH_ASSOC);
  9. for ($i=0;$i<$num;$i++){
  10. $art = $stmt->fetch();
  11. $tmpart[] = $art;
  12. $cat_ids[$i] = $tmpart[$i]['driver_id'];
  13.  
  14. }
  15. }
  16.  
  17. foreach ($cat_ids as $cat) {
  18.  
  19. $sql= 'select * from graph where driver = :driver';
  20. $stmt = $hDB->prepare($sql);
  21. $stmt->bindParam(':driver',$cat,PDO::PARAM_INT);
  22. $stmt->execute();
  23. $num = $stmt->rowCount();
  24.  
  25. if ($num>0){
  26. $arty = $stmt->setFetchMode(PDO::FETCH_ASSOC);
  27. for ($i=0;$i<$num;$i++){
  28. $arty = $stmt->fetch();
  29. $arty['note'] = html_entity_decode(stripslashes($arty['note']),ENT_QUOTES,'utf-8');
  30. $tmparty[$arty['driver']][] = $arty;
  31. }
  32.  
  33. }
  34.  
  35. }
  36. $smarty->assign('lsc',$tmpart);
  37. $smarty->assign('plsc',$tmparty);



nastepnie rysuję sobie wiersze i komórki:

  1. <!-- zawartośc tabel -->
  2. <div class="rightd" id="rightd">
  3. {section start=0 step=1 name=tmpart loop=$lsc}
  4. <div style="width:2765px;overflow:hidden;">
  5.  
  6. {assign var=idc value=$lsc[tmpart].drivers_id}
  7.  
  8. {section start=0 step=1 name=arty loop=52}
  9. {if $smarty.section.arty.rownum == $plsc[$idc][arty].week}
  10. <div data-week="{$smarty.section.arty.rownum}" data-driver_id="{$lsc[tmpart].driver_id}" data-driver_name="{$lsc[tmpart].name}" class="cell tips w{$smarty.section.arty.rownum}" id ="w{$smarty.section.arty.rownum}d{$lsc[tmpart].driver_id}" tip="week {$smarty.section.arty.rownum} " onClick="showdial('klasa', '500', this);" >
  11. 1
  12. </div>
  13. {else}
  14. <div data-week="{$smarty.section.arty.rownum}" data-driver_id="{$lsc[tmpart].driver_id}" data-driver_name="{$lsc[tmpart].name}" class="cell tips w{$smarty.section.arty.rownum}" id ="w{$smarty.section.arty.rownum}d{$lsc[tmpart].driver_id}" tip="week {$smarty.section.arty.rownum} " onClick="showdial('klasa', '500', this);" >
  15.  
  16. </div>
  17. {/if}
  18. {/section}
  19.  
  20.  
  21. <div class="clearing"></div>
  22.  
  23. </div>
  24. {/section}
  25. </div>
  26. <div class="clearing"></div>
  27. <!-- end zawartośc tabel -->



N i wiem,że w rysowaniu kkomórek jest zle bo póki co mam puste komórki i ani tak ani siak.
Poprosze o pomoc.
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: 23.08.2025 - 17:09