-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharmas etiquetas.php
26 lines (26 loc) · 935 Bytes
/
armas etiquetas.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?php
//conexion con base de datos
$conexion = mysqli_connect('localhost','root','','messuputo') or die ('No se puede conectar'.mysqli_error($conexion));
//peticion del primer arma requerida a la base de datos
$pedirn = 'SELECT id, name, description FROM armas WHERE id= "'.$_POST['id'].'"';
$result = mysqli_query($conexion, $pedirn);
$row = mysqli_fetch_array($result);
//almasenaje en la estructura data(json)
$data['id'] = $row['id'];
$data['name'] = $row['name'];
$data['description'] = $row['description'];
$array[1] = $data;
$i = $_POST['id'] + 1;
//peticion de las otras 15 armas
while($i<=($_POST['id']+15)){
$pedirn = 'SELECT name, description FROM armas WHERE id="'.$i.'"';
$result = mysqli_query($conexion, $pedirn);
$row = mysqli_fetch_array($result);
$data['name'] = $row['name'];
$data['description'] = $row['description'];
$array[$i] = $data;
$i++;
}
//devolucion
echo json_encode($array);
?>