Advertisement
Guest User

Untitled

a guest
Sep 11th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. $servername = "localhost";
  2. $username = "root";
  3. $password = "";
  4. $dbname = "tablename";
  5. $conn = new mysqli($servername, $username, $password, $dbname);
  6. if ($conn->connect_error) {die("Connection failed: " . $conn->connect_error);}
  7. $sql = "SELECT * FROM wp_posts WHERE post_type = 'attachment' ORDER BY ID DESC LIMIT 3";
  8. $result = $conn->query($sql);
  9. if ($result->num_rows > 0) {
  10.  
  11. while($row = $result->fetch_assoc()) {
  12. echo '<div class="col-sm-4">';
  13. echo "Post ID: " . $row["ID"] . " / ";
  14. echo "Post Title: " . $row["post_title"] . " / ";
  15. echo "Post Title: " . $row["post_date"] . " / ";
  16. echo '<img src="' . $row['guid'] . '" class="img-responsive">';
  17. echo '</div>';
  18. }
  19. } else {
  20. echo "0 results";
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement