SMS처리 도우미
질문답변 일반

datatable 강의 sql 관련 질문드립니다

작성자 홀스 작성일 2020-12-02 10:40:08 조회수 7366 E-mail chuksan01@gmail.com
압축 1.65 KBZIP
2020_search_1.zip

안녕하세요 datatable 관련 문의드립니다 

꾸준히 강의 듣고 있는데 초보자로써 많은 도움이 되고 있습니다만

해결되지 않는 부분이 있어 질문드립니다 

html 문서에 검색조건을 입력하여 datatable을 구현하려고 합니다 

search.html 에서 검색조건 입력 -> seaech_1.php 에서 검색조건을 받아 sql문처리 -> search_1_result.php에서 sql문 을 받아 자료 만들어 search.html 문에 넘겨 datatable 완성하려고 합니다.

html의 검색 조건 양식입니다 

     //  

         

                 

 

         

 

         


       

 

 

이때 seaech_1.php 에  sql 조건문을 직접 입력하면 잘 처리가 되어 datatable 이 잘 표현됩니다 

$conn=mysqli_connect('localhost','root', 'livestock01','milk');

$SQL = "select id, school_city, school_gun, school_name, supply_group, supply_name, bid_price, bid_rank, supply_sum from bidresult where bid_rank='1' and supply_year='2020'";

조건문을 echo $sql로 처리하면 아래와 같이 나옵니다

select id, school_city, school_gun, school_name, supply_group, supply_name, bid_price, bid_rank, supply_sum from bidresult where bid_rank='1' and supply_year='2020'

 

 

그러나  아래와 같이 html문의 form에서 받은 조건을 대입하면 에러가 발생합니다 

$conn=mysqli_connect('localhost','root', 'livestock01','milk');

$SQL = "select id, school_city, school_gun, school_name, supply_group, supply_name, bid_price, bid_rank, supply_sum from bidresult where bid_rank='1' and supply_year='".$_POST['supply_year']."'";

조건문을 echo $sql로 처리하면 직접입력한 쿼리문과 똑 같습니다 

select id, school_city, school_gun, school_name, supply_group, supply_name, bid_price, bid_rank, supply_sum from bidresult where bid_rank='1' and supply_year='2020'

 

html의 input type="text"  또는 input type="number" 로 해도 마찬가지입니다 

 

1. 어디를 수정해야 할지 알려주시면 고맙겠습니다.

제 생각에는  seaech_1.php 에서 수정해야 할 것 같은데 잘 모르겠습니다 

 

2. 또한 검색조건을 받아 처리하는 경우 

초기 검색조건 값이 입력되지 않아 에러가 발생하는 것 같습니다 이때 에러가 발생하지 않도록 하려면 어떨게 해야 하는지요.

 

에러문

DataTables warning: table id=example - Invalid JSON response. For more information about this error, please see http://datatables.net/tn/1 

 

첨부파일에는 3가지 문서를 올리겠습니다 

건강하십시요. 항상 친절한 답변 감사합니다 

 

 


Recent Posts

질문답변 최근 글

질문답변 게시판의 최근 글입니다.

일반 2025-04-28

mcp오류

Write Comment

댓글 작성

X
로그기록