w bazie mam takie wpisy:
Kod
id_kategori_other | id_kategori
1                         | 20
2                         | 20
10                        | 20
5                         | 30

i baza z kategoriami
Kod
id | label | parent
1 | cos    | 0
.. | ..       | ..
20 | cos20 | 0

kod na samym dole wyswietla mi z drugiej bazy drzewko w select (typ multiple) (to dzial dobrze).
Tylko teraz probuje zrobic tak ze wybieram id_kategori_other z 1 bazy i jezeli
id=id_kategori_other to option jest zaznaczony. Problem w tym ze niewiem co wstawic zeby to sprawdzalo problowalem robic:
  1. <?
  2. while ($row2 = mysql_fetch_array($sql2)) {
  3. while($data = mysql_fetch_array($sql)) {
  4.  
  5. for($i=0;$i < $level; $i++) {
  6. $output2 .= &#092;"&nbsp;&nbsp;&nbsp;\";
  7. $output1 = &#092;"\";
  8. }
  9. $sub .= &#092;"<option value=\"$data[id]\"\";
  10. if ($data[id] == $row2[promo_kat_id]) {
  11. $sub .= &#092;" selected\";
  12. }
  13. $sub .= &#092;">$output2$data[label]</option>\";
  14. $sub .= ListCategoryForEdit($data[id],$level+1,$current,$data[id]);
  15. unset($output2);
  16. }
  17. }
  18. ?>

ale to jednak nie to :/ i nie wiem jak to osciagnac sad.gif
  1. <?
  2. function ListCategoryForEdit($SQL_CONDITION,$level,$current,$current_id) {
  3. if(empty($SQL_CONDITION)) {
  4. $SQL_CONDITION = &#092;"0\";
  5. }
  6. if(empty($level)) {
  7. $level = 0;
  8. }
  9. if(empty($current)) {
  10. $current = 0;
  11.  
  12. }
  13. if(empty($current_id)) {
  14. $current_id = 0;
  15. }
  16. if (isset($current_id)) {
  17. $current_baza = &#092;"AND id !='$current_id'\";
  18. }
  19. $select = &#092;"SELECT * FROM menu WHERE parent = \". $SQL_CONDITION .\" $current_baza ORDER BY posy\";
  20. $sql = mysql_query($select);
  21. $sql2 = mysql_query(&#092;"SELECT id_kategori_other FROM test_baza WHERE id_kategori='$current_id'\"); //tym zapytaniem wybieram id_kategori_other zeby moc sprawdzic czy id=id_kategori_
  22. ther
  23. $row2 = mysql_fetch_row($sql2);
  24. $subcat_numrows = mysql_num_rows($sql);
  25. if ($subcat_numrows > 0) {
  26. $sub = &#092;"\";
  27. $output2 = &#092;"\"; 
  28. while($data = mysql_fetch_array($sql)) {
  29.  
  30. for($i=0;$i < $level; $i++) {
  31. $output2 .= &#092;"&nbsp;&nbsp;&nbsp;\";
  32. $output1 = &#092;"\";
  33. }
  34. //tu kod od wyswietlania optionów
  35. $sub .= &#092;"<option value=\"$data[id]\"\";
  36. if ($data[id] == $row2[promo_kat_id]) {
  37. $sub .= &#092;" selected\";
  38. }
  39. $sub .= &#092;">$output2$data[label]</option>\";
  40. $sub .= ListCategoryForEdit($data[id],$level+1,$current,$data[id]);
  41. unset($output2);
  42. }
  43.  
  44. }
  45. return $sub;
  46. }
  47. ?>