Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $dsn = 'mysql:host=localhost;dbname=diariowp';
- $username = 'root';
- $password = 'popadmin';
- try {
- $db = new PDO($dsn, $username, $password);
- echo "Database connected DIARIOWP <br><br>";
- } catch (PDOException $e) {
- $error_message = $e->getMessage();
- include('database_error.php');
- echo 'Error Connecting to DB <br>';
- exit();
- }
- $query = "SELECT id, post_title, post_content FROM wp_posts";
- $statement = $db->prepare($query);
- $statement->execute();
- $rows = $statement->fetchAll();
- $statement->closeCursor();
- echo '
- <table>
- <tr>
- <td>ID</td>
- <td>POST_TITLE</td>
- <td>POST_CONTENT</td>
- </tr>';
- foreach ( $rows as $row ) { ?>
- <tr class="<?php echo $bg; ?>">
- <td><?php echo $row['id']; ?></td>
- <td><?php echo $row['post_title']; ?></td>
- <td><?php echo $row['post_content']; ?></td>
- </tr>
- <?php }
- echo '
- </table>';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement