/ajax/in_use.php
PHP | 63 lines | 55 code | 8 blank | 0 comment | 15 complexity | 698c245fbced2d3f56f0cf38b2aff5d0 MD5 | raw file
Possible License(s): LGPL-3.0, LGPL-2.1
- <?php
- require_once '../utilidades/conexion.php';
- global $conexion;
-
- $filtro = $_POST["filtro"];
- $valor = $_POST["valor"];
-
- switch ($filtro) {
- case '../forms/e_editing.php?id=':
- $query = "select count(id_tipo_edicion) as total from t_libros where id_tipo_edicion = $valor";
- $result = mysql_query($query, $conexion);
- $row = mysql_fetch_array($result);
-
- if (intval($row["total"]) == 0) {
- $resultado["use"] = false;
- } else {
- $resultado["use"] = true;
- }
- break;
- case '../forms/e_editorial.php?id=':
- $query = "select count(id_editorial) as total from t_libros where id_editorial = $valor";
- $result = mysql_query($query, $conexion);
- $row = mysql_fetch_array($result);
-
- if (intval($row["total"]) == 0) {
- $resultado["use"] = false;
- } else {
- $resultado["use"] = true;
- }
- break;
- case '../forms/e_theme.php?id=':
- $query = "select count(id_tematica) as total from t_libros_tematica where id_tematica = $valor";
- $result = mysql_query($query, $conexion);
- $row = mysql_fetch_array($result);
-
- if (intval($row["total"]) == 0) {
- $resultado["use"] = false;
- } else {
- $resultado["use"] = true;
- }
- break;
- case '../forms/e_authors.php?id=':
- $query = "select count(id_autor) as total from t_libros_autores where id_autor = $valor";
- $result = mysql_query($query, $conexion);
- $row = mysql_fetch_array($result);
-
- $query2 = "select count(id_autor) as total from t_citas where id_autor = $valor";
- $result2 = mysql_query($query2, $conexion);
- $row2 = mysql_fetch_array($result2);
-
- if (intval($row["total"]) == 0 && intval($row2["total"]) == 0) {
- $resultado["use"] = false;
- } else {
- $resultado["use"] = true;
- }
- break;
- default:
- $resultado["use"] = false;
- break;
- }
-
- echo json_encode($resultado);
- ?>