-1
내 PHP 페이지를 사용하여 MySQL 데이터를 읽고 json에 표시합니다. PHP 페이지의 코드입니다 -null 값을 얻는 json 데이터를 읽는 중
<?php
function loadData($limit){
require "config.inc.php";
$query = $con->prepare("SELECT * FROM UploadText ORDER BY slno DESC LIMIT $limit ");
$query->execute();
$array = array();
while($data = $query->fetch(PDO::FETCH_ASSOC)){
$id = $data['slno'];
$title = $data['textmsg'];
array_push($array, array(
"id" => $id,
"title" => $title
)
);
}
echo json_encode($array);
}
function loadMoreData($lastId, $limit){
require "config.inc.php";
try{
$query = $con->prepare("SELECT * FROM UploadText WHERE slno < $lastId ORDER BY slno DESC LIMIT $limit ");
$query->execute();
$array = array();
while($data = $query->fetch(PDO::FETCH_ASSOC)){
$id = $data['slno'];
$title = $data['textmsg'];
array_push($array, array(
"id" => $id,
"title" => $title
)
);
}
echo json_encode($array);
} catch(Exception $e){
die($e->getMessage());
}
}
if(isset($_GET['action']) && $_GET['action'] == "apiText"){
$lastId = $_GET['lastId'];
// this is teh limit set in the android java code (LOAD_LIMIT)
$limit = $_GET['limit'];
loadMoreData($lastId, $limit);
} else {
$limit = $_GET['limit'];
loaddata($limit);
}
?>
을 그리고 이것은 위의 코드의 출력 - 왜 그 독서 null 값
[{"id":"14","title":"A Kid On His Way 2 Home With His Mom\r\nSaw A Couple Kissing On The Road,\r\nHe Suddenly Shouted & Said:\r\nLook Mom look, that boy and girl\r\nAre Fighting For A Chewing GUM."},
{"id":"13","title":null},
{"id":"12","title":null},
{"id":"11","title":null},
{"id":"10","title":"PAPPU : Daddy, have you\never been to Egypt?\nFATHER : No. Why do\nyou ask that?\nPAPPU: Well, where did\nyou get THIS mummy??"},
{"id":"9","title":"Y r u so opposite to me?\nWhen i say tea,u say coffee!\nI say white,u say black!\nI went to dental hospital,u went to mental hospital!\nI came back and u still there!"}]
하지 이해할 수. 데이터가 mysql 테이블에 있지만 일부 null 값을 읽고 일부 데이터가 올바르게 표시됩니다.
이
내 MySQL의 테이블의 구조 -![enter image description here](https://i.stack.imgur.com/e5xqw.png)
전 심장 녹는 사랑 이야기 : 소년 : 나는 결혼 할 수 없다. 우리 가족은 완전히 반대합니다. 여자 : 누가 r 2 그들은 당신을 멈 춥니? Boy : 내 아내와 2 명의 아이들. –
UTF-8? - 몰라 –