Created
August 19, 2014 01:00
-
-
Save hiro-matsuno/f794b78c84b4fd5c7192 to your computer and use it in GitHub Desktop.
PHPでJSONを作るための方法(データが決まっている場合)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//取得関数の初期化 | |
$blogReadList = array(); | |
//リザルトからJSON用変数への投入 | |
if(!empty($result)){ | |
while($row = mysql_fetch_array($result)){ | |
$blogReadList['blogId'] = isset($row['blogId'])? $row['blogId']:""; | |
$blogReadList['blogDate'] = isset($row['blogDate'])? $row['blogDate']:""; | |
$blogReadList['blogTitle'] = isset($row['blogTitle'])? $row['blogTitle']:""; | |
$blogReadList['blogContent'] = isset($row['blogContent'])? $row['blogContent']:""; | |
$blogReadList['id'] = isset($row['id'])? $row['id']:""; | |
} | |
} | |
//JSON配列化 | |
echo json_encode($blogReadList); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment