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 ...
$qry="SELECT * FROM nowy_test";
$result=mysql_query($qry);
$arrayCategories = array();
while($row = mysql_fetch_assoc($result)){
$arrayCategories[$row['Key']] = array("Parent_ID" => $row['Parent_ID'], "Classification_Name_pl" =>
$row['Classification_Name_pl'], "Classification_Name_de" => $row['Classification_Name_de'], "Classification_Name_en" => $row['Classification_Name_en'], "PM" => $row['PM'], "Stepkey" => $row['Stepkey'],
"Comments" => $row['Comments'], "OKNO" => $row['OKNO']);
}
//createTree($arrayCategories, 0);
function createTree($array, $currentParent, $currLevel = 0, $prevLevel = -1) {
foreach ($array as $categoryId => $category) {
if ($currentParent == $category['Parent_ID']) {
/*echo "<li>
<label for='folder2'>Folder 2</label> <input type='checkbox' id='folder2' />
<ol>
<li class='file'><a href=''>File 1</a></li>
<li>
<label for='subfolder2'>Subfolder 1</label> <input type='checkbox' id='subfolder2' />
<ol>
<li class='file'><a href=''>Subfile 1</a></li>
<li class='file'><a href=''>Subfile 2</a></li>
<li class='file'><a href=''>Subfile 3</a></li>
<li class='file'><a href=''>Subfile 4</a></li>
<li class='file'><a href=''>Subfile 5</a></li>
<li class='file'><a href=''>Subfile 6</a></li>
</ol>
</li>
</ol>
</li>";*/
if ($currLevel > $prevLevel) echo " <ol class='tree'> ";
if ($currLevel == $prevLevel) echo " </li> ";
echo '<li> <label for="subfolder2"> | <img src="'.$category['OKNO'].'.png"> | <img src="comment.png"> <span class="akceptacja">'.$category['Comments'].'</span>
| <a href="edit.php?Stepkey='.$category['Stepkey'].'&PM='.$_GET['PM_NAME'].'"><img src="edit.png"></a>
| <img src ="http://www.wisniewski.net/polish_flag_icon.png"> '.$category['Classification_Name_pl'].'
| <img src="http://fr.custplace.com/img/flag-deu.png?1392218467"> '.$category['Classification_Name_de'].'
| <img src="http://www.neue-volkslieder.de/social/english.png"> '.$category['Classification_Name_en'].'
| <img src="Person.png"> '.$category['PM'].'
| </label> <input type="checkbox" id="subfolder2"/>';
if ($currLevel > $prevLevel) { $prevLevel = $currLevel; }
$currLevel++;
createTree ($array, $categoryId, $currLevel, $prevLevel);
$currLevel--;
}
}
if ($currLevel == $prevLevel) echo " </li> </ol> ";
}
?>
<div id="content" class="general-style1">
<?php
{
createTree($arrayCategories, 0);
}
?>
Ten post edytował pikasso 14.05.2015, 14:05:25