Advertisement
Guest User

Untitled

a guest
Feb 27th, 2016
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. <?php
  2.  
  3. $DB_host = "localhost";
  4. $DB_user = "root";
  5. $DB_pass = "";
  6. $DB_name = "news_spots";
  7. $options = array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf-8');
  8. try
  9. {
  10. $DB_con = new PDO("mysql:host={$DB_host};dbname={$DB_name}",$DB_user,$DB_pass);
  11. $DB_con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  12. $DB_con->exec('SET NAMES utf8');
  13. }
  14. catch(PDOException $e)
  15. {
  16. $e->getMessage();
  17. }
  18.  
  19. $stmt = $DB_con->prepare("SELECT FROM news");
  20.  
  21. while($row=$stmt->fetch(PDO::FETCH_ASSOC))
  22. {
  23. echo
  24. '
  25.  
  26. <p style="color:red !important;">'.$row["name_news"].'</p>
  27. ';
  28.  
  29. }
  30. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement