Y
Y
yerdnaandrey2020-05-18 21:14:22
PHP
yerdnaandrey, 2020-05-18 21:14:22

Why is it only showing one line?

Why is only one line displayed from the database, but I have eight of them.

<?php
                $connect1 = new mysqli("localhost", "root", "root", "firecode");
                $connect1_title = $connect1->query("SELECT * FROM `articles`");
                $connect1_title = $connectt1_title->fetch_assoc();

                foreach ($connect1_title as $comment){   ?>

                <p class="article-style-title"><?= $comment;?></p> <br>
                <? }?>

Tell me please.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
nokimaro, 2020-05-18
@nokimaro

<?php
$connect1 = new mysqli("localhost", "root", "root", "firecode");
$connect1_title = $connect1->query("SELECT * FROM `articles`");

while($comment = $connect1_title->fetch_assoc())
{
    print_r($comment);
}

R
Rsa97, 2020-05-18
@Rsa97

Because fetch_assoc only returns one row from the fetch

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question