Page 199 - 3-2
P. 199
while True:
cur.execute("select * from state")
rows=cur.fetchone()
#print("t_l"+str(rows[1]))
print(rows[1]+"/"+buff)
if rows[1] != buff:
print("buff"+buff)
ser.write(rows[1])
#print("t_l"+str(rows[1]))
else:
ser.write("0")
if not ser.read():
data=''
else:
data=ser.read()
print(data)
cur.execute("update state set c_l=%s" %(data))
conn.commit()
buff=rows[1]
except Exception as e:
print(e)
#ser.write("2")
라. PHP 소스
* mdp.php
<?php
// array for JSON response
$response = array();
// 데이터베이스 접속 문자열. (db 위치 유저 이름 비밀번호, , )
$connect=mysqli_connect("localhost", "root", "", "MDP") or
die( "SQL server 에 연결할 수 없습니다.");
//mysqli_query("SET NAMES UTF8");
// 데이터베이스 선택
//mysqli_select_db($connect,"and1") or die('DB 선택 실패');
// 세션 시작
//session_start();
// 쿼리문 생성
$sql = "select * from state";
// 쿼리 실행 결과를 $result 에 저장
- 199 -