Advertisement
Guest User

Untitled

a guest
Dec 19th, 2016
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. <?php
  2.  
  3. $username = "prevod";
  4. $password = "Pr3V0Dd!18";
  5. $hostname = "prevod.db.10770226.hostedresource.com";
  6.  
  7.  
  8. //Establishing connection
  9.  
  10. $conn = mysql_connect ($hostname, $username, $password)
  11. or die ("Unable to connect to the database");
  12.  
  13. //selekcija baze
  14.  
  15. $selected = mysql_select_db ("prevod", $conn)
  16. or die ("Can't find database.");
  17.  
  18. //fetchovanje podataka iz bazu
  19.  
  20. $result = mysql_query("SELECT IF(post_type='attachment',guid,''), post_content, post_title, post_excerpt FROM wp_posts WHERE post_type='product' OR post_mime_type='image/jpeg'");
  21. $rows =array();
  22. while ($r = mysql_fetch_assoc($result)) {
  23.  
  24. $rows['object_name'][] = $r;
  25.  
  26. }
  27. header("Content-Type: application/json; charset=utf-8", true);
  28. print json_encode($rows);
  29.  
  30.  
  31. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement