아래 mysql 쿼리문 좀 살펴주세요.

kimyh의 이미지

php와 mysql을 공부하고 있는 초보 입니다.
공부 좀 할겸 지금 사주 운세 보는 프로그램을 만들고 있습니다.
아래는 만세력 데이터 베이스를 이용하여 대운이 들어있는 행운세수를 구하고자 는 루틴의 일부 입니다.

아래 부분은 먼저 행운세수를 구하기위해 생일이 들어있는 해당월의 절기와 절기가 들어있는 날짜를 뽑는 프로그램을 만드는 중닌데 안되는군요.

절기는 매월 두번씩 들어있는데 생일이들어있는 달의 절기와 날짜를 우선 두개씩 다 뽑을려고 하는 겁니다.


echo"입력된 음력의 년도: $cd_ly, 입력된 음력의 달: $cd_lm, 입력된 성별:$sex ,입력된 년도의 간지: $y_gan<br>"; 
 
//대운이 들어간 해의 행운세수를 뽑는 루틴 시작     
//먼저 해당 생년, 생월의 절기와 절입일을 뽑는다 
    if (($sex == '남성') and (($y_gan == '갑') or ($y_gan == '병') or ($y_gan == '무') or ($y_gan == '경') or ($y_gan == '임'))) 
    {        
        if (($cd_lm != '12') or (($cd_lm == '12') and ($cd_lm < 16))){  //생월이 12월이 아니거나 12월이어도 생일이 16일 이전이면.. 
        for ($i = 1; $i < 30; $i++){         
        //해당년도의 1월부터 11월까지의 해당월의 절입일을 구하고 
        $QUE="select cd_kterms, cd_ld from $tojung_databases03 where cd_ly = $cd_ly && cd_lm = $cd_lm && cd_ld = $i && cd_kterms is not NULL group by cd_kterms";    
        $result = mysql_query($QUE); 
        $res = mysql_fetch_array($result); 
        $cd_kterms=$res[cd_kterms]; 
        $cd_ld_term=$res[cd_ld]; 
 
        $cd_kterms.= $cd_kterms; 
        $cd_ld_term.= $cd_ld_term; 
                    $i.=$i; 
        } 
 
        echo"$i, 생월이 12월이 아니면, 절기:$cd_kterms, 절입일:$cd_ld_term, 디비명:$tojung_databases03, 입력된 생년:$cd_ly, 입력된 생월$cd_lm<br>";         
 
        } else if (($cd_lm == '12') && ($cd_ld > 15)){  //생월이 음력 12월이면서 생일이 16일 부터이면 12월에 절기가 없으므로 다음해 1월의 절입일을 구한다. 
        $cd_ly_add = ($cd_ly + 1);  //다음 해 
         $cd_lm_add = '1';  //다음해 1월 
 
        //다음해의 1월의 절입일을 구하고 
        for ($i = 1; $i < 30; $i++){ 
        $QUE="select cd_kterms, cd_ld from $tojung_databases03 where cd_ly = $cd_ly_add && cd_lm = $cd_lm_add && cd_ld = $i && cd_kterms is not NULL group by cd_kterms";    
        $result = mysql_query($QUE); 
        $res = mysql_fetch_array($result); 
        $cd_kterms=$res[cd_kterms]; 
        $cd_ld_term=$res[cd_ld]; 
        $cd_kterms.= $cd_kterms; 
        $cd_ld_term.= $cd_ld_term; 
                    $i.=$i; 
        } 
        echo"$i, 생월이 12월이면, 절기:$cd_kterms, 절입일:$cd_ld_term, 디비명:$tojung_databases03, 입력된 생년:$cd_ly, 입력된 생월$cd_lm<br>";         
 
        } else {;} 

그런데 절기나 절입일 모두 아예 나오지를 않는군요.
제가 아무리 봐도 쿼리문을 제대로 만들지 못한것 같습니다.
위의 echo문 두개로 확인해보면 입력된 값들은 제대로 나오는데 아래와 같이 결과가 나오는데 경험 많으신 선배님들 도와 주시면 감사하겠습니다..

입력된 음력의 년도: 1972, 입력된 음력의 달: 4, 입력된 성별:남성 ,입력된 년도의 간지: 임
1213, 생월이 12월이 아니면, 절기:NULLNULL, 절입일:1212, 디비명:calenda_data, 입력된 생년:1972, 입력된 생월4

디비에서 직접 확인 해보면 실제 절기는 소만 하고 망종이 4월9일과 24일에 들어 있거든요.

며칠전에 비슷한 질문을 올렸는데도 아직 해결을 못하고 있습니다.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.