"stifinder" system i niveau'er
Hejsa, Jeg er igang med at lave noget "stifinder" lignende noget.Dog uden rigtige mapper (hvis det giver mening)
pointen er at kunne oprette punkter og dertil underpunkter.. osv.. som kan indeholde tekst.(+nogle andre funktioner, når jeg er så vidt).
Det inkluderer dog både noget mysql såvel som javascript. men det bærene element er PHP, så jeg håber spørsmålet ligger rigtigt.
Mit problem består af at over og under mapper rigtigt nok ligger på samme niveau, men at niveau'erne bliver blandet.
eks.:
|1|<- alt lukkes herefter
|2|<- alt lukkes herefter
|3|<- alt lukkes herefter
|1|<- alt lukkes herefter.. og så fremdeles
|2|
|1|
|2|
|3|
ønsket:
|1|<- 2+3 lukkes
|2|<- 3 lukkes
|3|<- tekst lukkes
|tekst|
|1|<- 2+3 lukkes
|2|<- 3 lukkes
|3|<- tekst lukkes
|tekst|
|2|<- 3 lukkes
|3|<- tekst lukkes
|tekst|
osv..
Jeg er desuden sikker på at det kan laves på en langt "lettere" måde. men jeg kan ikke lige gennemskue hvordan.
Jeg håber på nogle gode idéer/råd og rettelser.
På forhånd mange tak :-)
-----
databasen:
|id|navn|mappe_id|mappe_under_id|
Koden(unskyld længden):
<script type="text/javascript">
function showHideLayers(layerID)
{
if (document.getElementById)
{
obj = document.getElementById(layerID);
obj.style.display = (obj.style.display == "none" ? "block" : "none");
}
}
</script>
<script type="text/javascript" language="javascript">
billede1=new Image();
billede1.src="images/plus_red.gif";
billede2=new Image();
billede2.src="images/minus_red.gif";
function skiftbillede(id,src1,src2){
var o=document.getElementById(id);
o.title=o.src=o.getAttribute("title")==src1?src2:src1
}
</script>
<? //inkluder database forbindelse.
include("db.php");
// <--|| inkluder database forbindelse.
$a = 0;
$b = 0.12;
$c = 0.23;
$d = 0.34;
$e = 0.45;
$f = 0.56;
$g = 0.78;
$h = 0.910;
$i = 0.1112;
$j = 0.1314;
$k = 0.1516;
$l = 0.1718;
$m = 0.1920;
$n = 0.2122;
$o = 0.2324;
$p = 0.2526;
$q = 0.2728;
$r = 0.2930;
$s = 0.3132;
$t = 0.3334;
// ||--> niveau 1
$foresp1 = mysql_query("SELECT * FROM mapper_check WHERE m_u_id = 0 ORDER BY m_u_id")or die(mysql_error());
while($data1 = mysql_fetch_array($foresp1)){
$navn = $data1[navn];
$m_id = $data1[m_id];
$m_u_id = $data1[m_u_id];
$a++;
$b++;
echo "<a href=\"java script:void(0)\" onClick=\"skiftbillede('$b','images/plus_red.gif','images/minus_red.gif') , showHideLayers('$a')\"><img id=\"$b\" title=\"images/plus_red.gif\" src=\"images/plus_red.gif\" alt=\"åbn/luk\" border=\"0\"></a> ".$navn." id:".$m_id." uid:".$m_u_id."<br><div id=\"$a\" style=\"display: none\">";
// ||--> niveau 2
$foresp2 = mysql_query("SELECT * FROM mapper_check WHERE m_u_id = $m_id ORDER BY m_u_id")or die(mysql_error());
while($data2 = mysql_fetch_array($foresp2)){
$navn = $data2[navn];
$m_id = $data2[m_id];
$m_u_id = $data2[m_u_id];
$c++;
$d++;
echo " <a href=\"java script:void(0)\" onClick=\"skiftbillede('$d','images/plus_red.gif','images/minus_red.gif') , showHideLayers('$c')\"><img id=\"$d\" title=\"images/plus_red.gif\" src=\"images/plus_red.gif\" alt=\"åbn/luk\" border=\"0\"></a> ".$navn." id:".$m_id." uid:".$m_u_id."<br><div id=\"$c\" style=\"display: none\">";
// ||--> niveau 3
$foresp3 = mysql_query("SELECT * FROM mapper_check WHERE m_u_id = $m_id ORDER BY m_u_id")or die(mysql_error());
while($data3 = mysql_fetch_array($foresp3)){
$navn = $data3[navn];
$m_id = $data3[m_id];
$m_u_id = $data3[m_u_id];
$e++;
$f++;
echo " <a href=\"java script:void(0)\" onClick=\"skiftbillede('$f','images/plus_red.gif','images/minus_red.gif') , showHideLayers('$e')\"><img id=\"$f\" title=\"images/plus_red.gif\" src=\"images/plus_red.gif\" alt=\"åbn/luk\" border=\"0\"></a> ".$navn." id:".$m_id." uid:".$m_u_id."<br><div id=\"$e\" style=\"display: none\">";
// ||--> niveau 4
$foresp4 = mysql_query("SELECT * FROM mapper_check WHERE m_u_id = $m_id ORDER BY m_u_id")or die(mysql_error());
while($data4 = mysql_fetch_array($foresp4)){
$navn = $data4[navn];
$m_id = $data4[m_id];
$m_u_id = $data4[m_u_id];
$g++;
$h++;
echo " <a href=\"java script:void(0)\" onClick=\"skiftbillede('$h','images/plus_red.gif','images/minus_red.gif') , showHideLayers('$g')\"><img id=\"$h\" title=\"images/plus_red.gif\" src=\"images/plus_red.gif\" alt=\"åbn/luk\" border=\"0\"></a> ".$navn." id:".$m_id." uid:".$m_u_id."<br><div id=\"$g\" style=\"display: none\">";
// ||--> niveau 5
$foresp5 = mysql_query("SELECT * FROM mapper_check WHERE m_u_id = $m_id ORDER BY m_u_id")or die(mysql_error());
while($data5 = mysql_fetch_array($foresp5)){
$navn = $data5[navn];
$m_id = $data5[m_id];
$m_u_id = $data5[m_u_id];
$i++;
$j++;
echo " <a href=\"java script:void(0)\" onClick=\"skiftbillede('$j','images/plus_red.gif','images/minus_red.gif') , showHideLayers('$i')\"><img id=\"$j\" title=\"images/plus_red.gif\" src=\"images/plus_red.gif\" alt=\"åbn/luk\" border=\"0\"></a> ".$navn." id:".$m_id." uid:".$m_u_id."<br><div id=\"$i\" style=\"display: none\">";
// ||--> niveau 6
$foresp6 = mysql_query("SELECT * FROM mapper_check WHERE m_u_id = $m_id ORDER BY m_u_id")or die(mysql_error());
while($data6 = mysql_fetch_array($foresp6)){
$navn = $data6[navn];
$m_id = $data6[m_id];
$m_u_id = $data6[m_u_id];
$k++;
$l++;
echo " <a href=\"java script:void(0)\" onClick=\"skiftbillede('$l','images/plus_red.gif','images/minus_red.gif') , showHideLayers('$k')\"><img id=\"$l\" title=\"images/plus_red.gif\" src=\"images/plus_red.gif\" alt=\"åbn/luk\" border=\"0\"></a> ".$navn." id:".$m_id." uid:".$m_u_id."<br><div id=\"$k\" style=\"display: none\">";
// ||--> niveau 7
$foresp7 = mysql_query("SELECT * FROM mapper_check WHERE m_u_id = $m_id ORDER BY m_u_id")or die(mysql_error());
while($data7 = mysql_fetch_array($foresp7)){
$navn = $data7[navn];
$m_id = $data7[m_id];
$m_u_id = $data7[m_u_id];
$m++;
$n++;
echo " <a href=\"java script:void(0)\" onClick=\"skiftbillede('$n','images/plus_red.gif','images/minus_red.gif') , showHideLayers('$m')\"><img id=\"$n\" title=\"images/plus_red.gif\" src=\"images/plus_red.gif\" alt=\"åbn/luk\" border=\"0\"></a> ".$navn." id:".$m_id." uid:".$m_u_id."<br><div id=\"$m\" style=\"display: none\">";
// ||--> niveau 8
$foresp8 = mysql_query("SELECT * FROM mapper_check WHERE m_u_id = $m_id ORDER BY m_u_id")or die(mysql_error());
while($data8 = mysql_fetch_array($foresp8)){
$navn = $data8[navn];
$m_id = $data8[m_id];
$m_u_id = $data8[m_u_id];
$o++;
$p++;
echo " <a href=\"java script:void(0)\" onClick=\"skiftbillede('$p','images/plus_red.gif','images/minus_red.gif') , showHideLayers('$o')\"><img id=\"$p\" title=\"images/plus_red.gif\" src=\"images/plus_red.gif\" alt=\"åbn/luk\" border=\"0\"></a> ".$navn." id:".$m_id." uid:".$m_u_id."<br><div id=\"$o\" style=\"display: none\">";
// ||--> niveau 9
$foresp9 = mysql_query("SELECT * FROM mapper_check WHERE m_u_id = $m_id ORDER BY m_u_id")or die(mysql_error());
while($data9 = mysql_fetch_array($foresp9)){
$navn = $data9[navn];
$m_id = $data9[m_id];
$m_u_id = $data9[m_u_id];
$q++;
$r++;
echo " <a href=\"java script:void(0)\" onClick=\"skiftbillede('$r','images/plus_red.gif','images/minus_red.gif') , showHideLayers('$q')\"><img id=\"$r\" title=\"images/plus_red.gif\" src=\"images/plus_red.gif\" alt=\"åbn/luk\" border=\"0\"></a> ".$navn." id:".$m_id." uid:".$m_u_id."<br><div id=\"$q\" style=\"display: none\">";
// ||--> niveau 10
$foresp10 = mysql_query("SELECT * FROM mapper_check WHERE m_u_id = $m_id ORDER BY m_u_id")or die(mysql_error());
while($data10 = mysql_fetch_array($foresp10)){
$navn = $data10[navn];
$m_id = $data10[m_id];
$m_u_id = $data10[m_u_id];
$s++;
$t++;
echo " <a href=\"java script:void(0)\" onClick=\"skiftbillede('$t','images/plus_red.gif','images/minus_red.gif') , showHideLayers('$s')\"><img id=\"$t\" title=\"images/plus_red.gif\" src=\"images/plus_red.gif\" alt=\"åbn/luk\" border=\"0\"></a> ".$navn." id:".$m_id." uid:".$m_u_id."<br><div id=\"$s\" style=\"display: none\">";
echo "</div></div></div></div></div></div></div></div></div></div>";
}}}}}}}}}}
?>