PageRenderTime 49ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/ajax/in_use.php

https://bitbucket.org/veroreinah/bookworm
PHP | 63 lines | 55 code | 8 blank | 0 comment | 15 complexity | 698c245fbced2d3f56f0cf38b2aff5d0 MD5 | raw file
Possible License(s): LGPL-3.0, LGPL-2.1
  1. <?php
  2. require_once '../utilidades/conexion.php';
  3. global $conexion;
  4. $filtro = $_POST["filtro"];
  5. $valor = $_POST["valor"];
  6. switch ($filtro) {
  7. case '../forms/e_editing.php?id=':
  8. $query = "select count(id_tipo_edicion) as total from t_libros where id_tipo_edicion = $valor";
  9. $result = mysql_query($query, $conexion);
  10. $row = mysql_fetch_array($result);
  11. if (intval($row["total"]) == 0) {
  12. $resultado["use"] = false;
  13. } else {
  14. $resultado["use"] = true;
  15. }
  16. break;
  17. case '../forms/e_editorial.php?id=':
  18. $query = "select count(id_editorial) as total from t_libros where id_editorial = $valor";
  19. $result = mysql_query($query, $conexion);
  20. $row = mysql_fetch_array($result);
  21. if (intval($row["total"]) == 0) {
  22. $resultado["use"] = false;
  23. } else {
  24. $resultado["use"] = true;
  25. }
  26. break;
  27. case '../forms/e_theme.php?id=':
  28. $query = "select count(id_tematica) as total from t_libros_tematica where id_tematica = $valor";
  29. $result = mysql_query($query, $conexion);
  30. $row = mysql_fetch_array($result);
  31. if (intval($row["total"]) == 0) {
  32. $resultado["use"] = false;
  33. } else {
  34. $resultado["use"] = true;
  35. }
  36. break;
  37. case '../forms/e_authors.php?id=':
  38. $query = "select count(id_autor) as total from t_libros_autores where id_autor = $valor";
  39. $result = mysql_query($query, $conexion);
  40. $row = mysql_fetch_array($result);
  41. $query2 = "select count(id_autor) as total from t_citas where id_autor = $valor";
  42. $result2 = mysql_query($query2, $conexion);
  43. $row2 = mysql_fetch_array($result2);
  44. if (intval($row["total"]) == 0 && intval($row2["total"]) == 0) {
  45. $resultado["use"] = false;
  46. } else {
  47. $resultado["use"] = true;
  48. }
  49. break;
  50. default:
  51. $resultado["use"] = false;
  52. break;
  53. }
  54. echo json_encode($resultado);
  55. ?>