Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $servername = "localhost";
- $username = "root";
- $password = "";
- $dbname = "tablename";
- $conn = new mysqli($servername, $username, $password, $dbname);
- if ($conn->connect_error) {die("Connection failed: " . $conn->connect_error);}
- $sql = "SELECT * FROM wp_posts WHERE post_type = 'attachment' ORDER BY ID DESC LIMIT 3";
- $result = $conn->query($sql);
- if ($result->num_rows > 0) {
- while($row = $result->fetch_assoc()) {
- echo '<div class="col-sm-4">';
- echo "Post ID: " . $row["ID"] . " / ";
- echo "Post Title: " . $row["post_title"] . " / ";
- echo "Post Title: " . $row["post_date"] . " / ";
- echo '<img src="' . $row['guid'] . '" class="img-responsive">';
- echo '</div>';
- }
- } else {
- echo "0 results";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement