Guest User

Untitled

a guest
Oct 11th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. <?php
  2. require 'config.php';
  3. require 'Slim/Slim.php';
  4. $dns = "mysql:host=localhost;dbname=geoclock";
  5. $user = "root";
  6. $pass = "";
  7. try {
  8. $con = new PDO($dns, $user, $pass);
  9. if(!$con){
  10. echo "No se puede conectar a la base de datos";
  11. }
  12. $query = $con->prepare('SELECT * FROM marcas order by marca_id desc limit 1');
  13. $query->execute();
  14. $registros = "[";
  15. while($result = $query->fetch()){
  16. if ($registros != "[") {
  17. $registros .= ",";
  18. }
  19. $registros .= '{"marca_id": "'.$result["marca_id"].'"}';
  20. }
  21. $registros .= "]";
  22. echo $registros;
  23. } catch (Exception $e) {
  24. echo "Erro: ". $e->getMessage();
  25. };
  26.  
  27. mysql_close();
  28.  
  29. ?>
Add Comment
Please, Sign In to add comment