Answer the question
In order to leave comments, you need to log in
How to write a script to automatically build a ref tree?
Guys, the next question. We need a script that, based on this database, would build a tree. The task is interesting, and something tells me that it is elementary. This is what brought me into a stupor:
parent is the one who is OVER the person. The one who is UNDER is not registered in the database. And I'm a little confused.
Please help me on the best way to accomplish this task.
Here is a screenshot of the table
Answer the question
In order to leave comments, you need to log in
You define a variable r1 and then use p instead. The else if conditions are written backwards. When cast to a number, the same variable is written differently.
function f1(){
var nu1, nu2, r1;
nu1 = document.getElementById('n1').value;
nu1 = parseInt(nu1);
nu2 = document.getElementById('n2').value;
nu2 = parseInt(nu2);
r1 = document.getElementById('r');
if (nu1>nu2){
r1.innerHTML = 'Первое число больше второго!';
}
else if(nu1==nu2){
r1.innerHTML = 'Числа равны!!';
}
else{
r1.innerHTML = 'Второе число больше первого!';
}
}
Google nested sets
There are a lot of materials on the net.
And normal forms are violated in the database - you have several columns parent, parent2, ...
In this case, they must be moved to a separate table, otherwise problems will arise in the future.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question