[Solved] How to show all DB result with PDO


The answer is as follows:

<?php
                            $sql = "SELECT * FROM database WHERE id BETWEEN 1 AND 5";
                            $stmt = $conn->query($sql);
                            $stmt->execute();
                            while($row = $stmt->fetch(PDO::FETCH_OBJ)){
                            ?>
                                <tr>
                                    <td><b><?php echo $row->hours ?></b></td>
                                    <td><a href="#"></a></td>
                                    <td id="dayhour-1">
                                        <input type="text" class="form-control" id="1" value="<?php echo $row->username ?>">
                                    </td>
                                </tr>
                            <?php } ?>

This code will do it’s work. Its completely perfect PDO and it works 100%. A friend helped my out.

1

solved How to show all DB result with PDO