件名ごとに1件のデータベースを表示しようとしています。データベースファイルを1件の件名ごとに1件表示する方法
私はtext_one
、img_one
、分離、text_two
とimg_two
を持っていると思います。
しかし、今、それはtext_one
、img_one
分離、text_one
、img_one
、text_two
とimg_two
を表示します。
データベースの件名を重複して表示する方法を教えてください。あなたは結果を連結します$img
$first.=
としてのため$first_text =
と同じに$first_text .=
を変更する必要が
$product = mysqli_query($connection, "SELECT * FROM `fr` WHERE active = '1' AND product = '1' ");
while($rows = mysqli_fetch_assoc($product)){
if ($rows['text'] != NULL)
{
$text .= '<p class="lead">' . $rows['text'] .'</p>';
}
if ($rows['img'] != NULL)
{
$img .= '<img class="img-responsive" src="img/description/' . $rows['img'] . '" alt="">';
}
$products .= '<div class="content-section">
<div class="container">
<div class="row">
<p class="lead">' . $text.'</p>
<div class="col-sm-12" align="center"> '.$img.' </div>
</div>
</div>
</div>';
}
echo $products;
奇妙なコード...一つのこととして、ループブロックであるセクションを囲む中括弧を忘れてしまった:while(...){...} '。これは 'while'ループが' if($ rows ['first_text']!= NULL){...} 'ここの単一の次のコマンドにのみ適用されることを意味します – arkascha
そして$ textはどこから来ますか? – Twinfriends