lo que yo hago:
1) Instalar Xamp
https://www.apachefriends.org/es/index.html
(no usar claves, ni usuarios, test para probar simple)
2) Iniciar Xamp, iniciar Apacha e iniciar MySQL
3) ir a MySQL al dar click en Admin
View attachment 85715
4) Crear una base de datos llamada: test
Crear tabla: tabla1
Crea los campos: id, campo1, campo2
Ingresar algunos datos en id, campo1, campo2
View attachment 85716
View attachment 85717
5) Crear dos php:
settings.php
ObtieneDatos.php
settings.php
<?php
$link=mysqli_connect("localhost","root","","test")
or die(mysql_error());
?>
ObtieneDatos.php
<?php
header('Content-type: application/json; charset=utf-8');
error_reporting(-1);
ini_set('display_error','1');
include 'settings.php' ;
$acentos = $link->query("SET NAMES 'utf8'");
$query = "SELECT * FROM tabla1 order by id;"
or die ('Error'.mysqli_error($query));
$result=$link->query($query);
$cursos=array();
while($row=mysqli_fetch_array($result)){
$cursos[]=$row;
}
$json=json_encode($cursos);
echo $json;
?>
crea un carpeta por ejemplo llamada: phptestbasic
y dentro guarda: settings.php y ObtieneDatos.php
dicha carpeta phptestbasic debe estar en C:\xampp\htdocs\
View attachment 85718
6) Test el php: en el navegador escribir:
http://localhost/phptestbasic/ObtieneDatos.php
debe mostrar:
[{"0":"1","id":"1","1":"test1campo1","campo1":"test1campo1","2":"test1campo2","campo2":"test1campo2"},{"0":"2","id":"2","1":"test2campo1","campo1":"test2campo1","2":"test2campo2","campo2":"test2campo2"}]
SOLO si funciona hasta aqui, ya sea utilizando Xamp o el servidor, puedes seguir con la App
Para luego seguir con el App Android necesitas saber el IP, entonces
cmd -> ENTER -> y escribir ipconfig
te entregara la ip a usar en el link de tu APP
ejemplo: "
http://192.168.1.19/phptestbasic/ObtieneDatos.php/"