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:
<?
for($i=0;$i < $level; $i++) {
$output2 .= \" \";
$output1 = \"\";
}
$sub .= \"<option value=\"$data[id]\"\";
if ($data[id] == $row2[promo_kat_id]) {
$sub .= \" selected\";
}
$sub .= \">$output2$data[label]</option>\";
$sub .= ListCategoryForEdit($data[id],$level+1,$current,$data[id]);
}
}
?>
ale to jednak nie to :/ i nie wiem jak to osciagnac

<?
function ListCategoryForEdit($SQL_CONDITION,$level,$current,$current_id) {
if(empty($SQL_CONDITION)) { $SQL_CONDITION = \"0\";
}
$level = 0;
}
$current = 0;
}
$current_id = 0;
}
if (isset($current_id)) { $current_baza = \"AND id !='$current_id'\";
}
$select = \"SELECT * FROM menu WHERE parent = \". $SQL_CONDITION .\" $current_baza ORDER BY posy\";
$sql2 = mysql_query(\"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_ ther
if ($subcat_numrows > 0) {
$sub = \"\";
$output2 = \"\";
for($i=0;$i < $level; $i++) {
$output2 .= \" \";
$output1 = \"\";
}
//tu kod od wyswietlania optionów
$sub .= \"<option value=\"$data[id]\"\";
if ($data[id] == $row2[promo_kat_id]) {
$sub .= \" selected\";
}
$sub .= \">$output2$data[label]</option>\";
$sub .= ListCategoryForEdit($data[id],$level+1,$current,$data[id]);
}
}
return $sub;
}
?>
Ten post edytował lemming 25.08.2004, 14:03:57