0

Working on getting a page to build off of an array that is returned from a DB to post a story, not sure what it is not working. The page URL looks like this: https://ohcrap.ninja/games/ps4/article.php?id=1

Here is the code that should be generating the content:

        <?php

        $id = $_GET['id'];
        $query = mysqli_query($con,'SELECT * FROM `PS4` WHERE `id` =' .$id) or die(mysqli_error($con));
        while ($row = mysqli_fetch_array($query));
        // Echo page content
                echo "<div class='col s12 m12 l12'>";
                echo "<div class='card small grey darken-3'>";
                echo "<div class='card-stacked'>";
                echo "<div class='card-content'>";
                echo "$id";
                echo "<span class='card-title'>" . $row['title'] . "</span>";
                echo "<hr color='black'>";
                echo "<P>By:<i> " . $row['author'] . "</i></P>";
                echo "<P>Published: " . $row['published'] . "</P>"; 
                echo "<br>";
                echo "<P class='truncate'>" . $row['story'] . "</P>";
                echo "</div>";
                echo "</div>";
                echo "</div>";
                echo "</div>";
    ?>
2

1 Answer 1

1

Your while loop is not doing anything useful, because you're immediately ending it with that ;.

while ($row = mysqli_fetch_array($query)) {
    // all those echoes
}
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks that got it, I am not sure why I did not catch that one. I will accept the answer once it lets me!
I think it's also worth explicitly noting that the braces are required to do all those echoes even after the stray semicolon is removed, rather than just looping echo "<div class='col s12 m12 l12'>";

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.