I have mySQL table like:
userid left_refid right_ref_id
1 3 4
3 5 6
and so on. I want to go through the binary tree and display all userid, and left and right ref ids.
This is the code I used, but it prints 134 continuously.
function display_childs($parent) {
//$result = mysql_query("SELECT title FROM tree WHERE parent=".$parent.'";');
global $wpdb;
$prefix=$wpdb->prefix;
if($parent==0){
$parent=3;
}
$user_ref_1 = $wpdb->get_results( $wpdb->prepare("SELECT * FROM wp_user_reference WHERE user_id=".$parent."" ));
foreach($user_ref_1 as $urd)
{
echo $urd->user_id;
echo $urd->left_zone_id;
echo $urd->right_zone_id;
echo '<br>';
$user_idpass=$urd->user_id;
}
display_childs($user_idpass);
unset($user_idpass);
unset($parent);
}
display_childs(0);