Guest User

Untitled

a guest
Feb 20th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. ...
  2. $db = new db;
  3. ...
  4. $sql = "select * from `news`;
  5. $db->query($sql);
  6.  
  7. while($result = $db->fetch_array()) {
  8. $data[] = $result;
  9. }
  10. ...
  11. ...
  12. function query($sql) {
  13. ... sql validation etc...
  14.  
  15. ... connection happens in a nother function but for my example i wrote it down here...
  16. $connection = mysqli_connect($host,$db_user,$db_password);
  17. mysqli_select_db($database);
  18. return mysqli_query( $connection , $sql);
  19. }
  20.  
  21. function fetch_array($resp = 0, $assoc = 1) {
  22. ...validity checks of resp and assoc...
  23. return mysqli_fetch_array($rp, $assoc);
  24. }
  25. ...
Add Comment
Please, Sign In to add comment