primer commit

This commit is contained in:
Andros Fenollosa
2014-07-20 15:36:23 +02:00
parent f9d25ed389
commit ce40cf0872
46 changed files with 10953 additions and 0 deletions

36
server/obtenerLogros.php Normal file
View File

@ -0,0 +1,36 @@
<?php
if(isset($_GET['usuario'])) {
//Bibliotecas
require 'DB.class.php';
//Variables
$iIdUsu = $_GET['usuario'];
$sSQLLogros = 'SELECT id, titulo, descripcion, icono FROM logros';
$sSQLSelec = 'SELECT id_logro FROM realizaron WHERE id_usuario = ' . $iIdUsu;
$miDB = new DB();
$aFinal;
//Obtiene logros
$aFinal = $miDB->obtenerResultado($sSQLLogros);
//Obtiene los seleccionados
$aSelec = $miDB->obtenerResultado($sSQLSelec);
//Mezcla los seleccionados
foreach ($aFinal as $key => $value) {
//Añade un nuevo campo
$aFinal[$key]['realizaron'] = 0;
foreach($aSelec as $key2 => $value2) {
if($value2['id_logro'] == $aFinal[$key]['id']) {
$aFinal[$key]['realizaron'] = 1;
}
}
}
//Devuelve JSON
header('Content-Type: application/json');
echo $_GET['callback'] .'(' .json_encode($aFinal) . ')';
}
?>