Guest User

Untitled

a guest
Apr 20th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. SELECT count(*) FROM blog_posts WHERE category = 'hot_stuff' and published <= NOW();
  2.  
  3. $myCategory = 'hot_stuff';
  4. $myTable = 'blog_posts';
  5.  
  6. $sql = "SELECT count(*) FROM {$myTable} WHERE category = '{$myCategory}' and published <= NOW();";
  7.  
  8. $rowCount = $db->query($sql);
  9. echo $rowCount;
  10.  
  11. $pdo = new PDO($dsn, $user, $password);
  12.  
  13. $stmt = $pdo->prepare("SELECT COUNT(*) FROM your_table
  14. WHERE category = ? AND published <= CURDATE()");
  15.  
  16. $stmt->execute([$category]);
  17.  
  18. echo $stmt->fetchColumn();
Add Comment
Please, Sign In to add comment