PHPで顧客管理を作っています。
データベースから引っ張ってきた前回までのメモをメモ履歴エリアにまとめて表示したいと思っています。
データベースからデータ取り込み(userclass.php)
PHP
1while($stmt->FETCH()){ 2 $row = array( 3 'id'=>$id, 4 'username_kanji'=>$username_kanji, 5 'username_kana'=>$username_kana, 6 'tel'=>$tel, 7 'birthday'=>substr($birthday,0,4).("年").substr($birthday,4,-2).("月").substr($birthday,-2).("日"), 8 'last_day'=>$last_day, 9 'comment'=>$row["comment"].$comlast_day.$comment.PHP_EOL 10 ); 11 $_SESSION['userdata'] = $row; 12 }
表示(select.php)
PHP
1<?php echo htmlentities($_SESSION['userdata']['comment']) ?>
のように表記しているのですが、メモ毎に改行させたいと思っています。
以下のことは試してみましたが、改行できません。(半角スペースは空いたものがあります)
'comment'=>$row["comment"].$前回来店日.$メモ."\n"
'comment'=>$row["comment"].$前回来店日.$メモ."<br>"
'comment'=>$row["comment"].$前回来店日.$メモ.PHP_EOL
ご指摘いただいてコードの書き方を変えました。
問題はcomment部分で
PHP
1'comment'=>$row["comment"].$comlast_day.$comment.PHP_EOL
これで過去のメモを結合させて一気に表示させようとしたのですが、改行ができないことです。
とんちんかんなことをしているかもしれないのですが、改めてご指摘お願いします。
回答3件
あなたの回答
tips
プレビュー