쿼리질문입니다
본문
$recommend = "master";
$query01 = sql_fetch("SELECT * FROM member WHERE mb_id = '$recommend' and mb_package != ''");
$recommend2 = $query01["mb_recommend"];
$query02 = sql_fetch("SELECT * FROM member WHERE mb_id = '$recommend2' and mb_package != ''");
$recommend3 = $query02["mb_recommend"];
$query03 = sql_fetch("SELECT * FROM member WHERE mb_id = '$recommend3'and mb_package != ''");
$recommend4 = $query03["mb_recommend"];
$query04 = sql_fetch("SELECT * FROM member WHERE mb_id = '$recommend4'and mb_package != ''");
$recommend5 = $query04["mb_recommend"];
$query05 = sql_fetch("SELECT * FROM member WHERE mb_id = '$recommend5'and mb_package != ''");
if($query01["mb_id"] != ""){
$maching01 = $query01["mb_id"];
} else if ($query01["mb_id"] == "" && $query02["mb_id"] != ""){
$maching01 = $query02["mb_id"];
} else if ($query01["mb_id"] == "" && $query02["mb_id"] == "" && $query03["mb_id"] != ""){
$maching01 = $query03["mb_id"];
} else if ($query01["mb_id"] == "" && $query02["mb_id"] == "" && $query03["mb_id"] == "" && $query04["mb_id"] != ""){
$maching01 = $query04["mb_id"];
} else if ($query01["mb_id"] == "" && $query02["mb_id"] == "" && $query03["mb_id"] == "" && $query04["mb_id"] == "" && $query05["mb_id"] != ""){
$maching01 = $query05["mb_id"];
}
이와같이 추천인이 타고 올라가는데 ... 수가 무한일때
패키지가 있어야만 maching01~05로 선언하고싶을때
재귀 쿼리 사용이 익숙치 않아 도움 요청합니다...
!-->
답변을 작성하시기 전에 로그인 해주세요.