Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Widok drzewa w PHP z mysql, Długi czas ładowania
pikasso
post
Post #1





Grupa: Zarejestrowani
Postów: 67
Pomógł: 0
Dołączył: 8.07.2008
Skąd: Warszawa

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


Witam serdecznie,
mam takie pytanie gdyż zrobiłem na bazie przykładu ze strony www widok drzewa z mysql + php

Jednak drzewo jest na tyle duże, że działa to bardzo wolno .... jak mógłbym w tym przypadku zastosować np. ajaxa aby mógł jakoś dynamicznie pokazywać wyniki w tym drzewie

drzewo ładuje się około minuty ...

  1. $qry="SELECT * FROM nowy_test";
  2. $result=mysql_query($qry);
  3.  
  4.  
  5. $arrayCategories = array();
  6.  
  7. while($row = mysql_fetch_assoc($result)){
  8. $arrayCategories[$row['Key']] = array("Parent_ID" => $row['Parent_ID'], "Classification_Name_pl" =>
  9. $row['Classification_Name_pl'], "Classification_Name_de" => $row['Classification_Name_de'], "Classification_Name_en" => $row['Classification_Name_en'], "PM" => $row['PM'], "Stepkey" => $row['Stepkey'],
  10. "Comments" => $row['Comments'], "OKNO" => $row['OKNO']);
  11. }
  12. //createTree($arrayCategories, 0);
  13.  
  14. function createTree($array, $currentParent, $currLevel = 0, $prevLevel = -1) {
  15.  
  16. foreach ($array as $categoryId => $category) {
  17.  
  18. if ($currentParent == $category['Parent_ID']) {
  19. /*echo "<li>
  20. <label for='folder2'>Folder 2</label> <input type='checkbox' id='folder2' />
  21. <ol>
  22. <li class='file'><a href=''>File 1</a></li>
  23. <li>
  24. <label for='subfolder2'>Subfolder 1</label> <input type='checkbox' id='subfolder2' />
  25. <ol>
  26. <li class='file'><a href=''>Subfile 1</a></li>
  27. <li class='file'><a href=''>Subfile 2</a></li>
  28. <li class='file'><a href=''>Subfile 3</a></li>
  29. <li class='file'><a href=''>Subfile 4</a></li>
  30. <li class='file'><a href=''>Subfile 5</a></li>
  31. <li class='file'><a href=''>Subfile 6</a></li>
  32. </ol>
  33. </li>
  34. </ol>
  35. </li>";*/
  36. if ($currLevel > $prevLevel) echo " <ol class='tree'> ";
  37.  
  38. if ($currLevel == $prevLevel) echo " </li> ";
  39.  
  40. echo '<li> <label for="subfolder2"> | <img src="'.$category['OKNO'].'.png"> | <img src="comment.png"> <span class="akceptacja">'.$category['Comments'].'</span>
  41. | <a href="edit.php?Stepkey='.$category['Stepkey'].'&PM='.$_GET['PM_NAME'].'"><img src="edit.png"></a>
  42. | <img src ="http://www.wisniewski.net/polish_flag_icon.png"> '.$category['Classification_Name_pl'].'
  43. | <img src="http://fr.custplace.com/img/flag-deu.png?1392218467"> '.$category['Classification_Name_de'].'
  44. | <img src="http://www.neue-volkslieder.de/social/english.png"> '.$category['Classification_Name_en'].'
  45. | <img src="Person.png"> '.$category['PM'].'
  46. | </label> <input type="checkbox" id="subfolder2"/>';
  47.  
  48. if ($currLevel > $prevLevel) { $prevLevel = $currLevel; }
  49.  
  50. $currLevel++;
  51.  
  52. createTree ($array, $categoryId, $currLevel, $prevLevel);
  53.  
  54. $currLevel--;
  55. }
  56.  
  57. }
  58.  
  59. if ($currLevel == $prevLevel) echo " </li> </ol> ";
  60.  
  61. }
  62. ?>
  63. <div id="content" class="general-style1">
  64. <?php
  65. if(mysql_num_rows($result)!=0)
  66. {
  67.  
  68. createTree($arrayCategories, 0);
  69. }
  70. ?>


Ten post edytował pikasso 14.05.2015, 14:05:25


--------------------
https://krasniej.pl Kancelaria Adwokacka Gocław Warszawa
Go to the top of the page
+Quote Post

Posty w temacie


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 Aktualny czas: 20.08.2025 - 05:52