Ver Mensaje Individual
  #3 (permalink)  
Antiguo 29/12/2014, 14:24
rahe_meph
 
Fecha de Ingreso: marzo-2013
Mensajes: 26
Antigüedad: 11 años, 1 mes
Puntos: 0
Respuesta: Caracteristicas requeridas para una aplicación

son consultas simples, este es el script ... mi pregunta es necesito un servidor dedicado o vps? o bastaria con uno compartido? el tema es el dinero, mientras mas barato mejor, necesito lo justo.
Código PHP:
Ver original
  1. require("../conexion.php");
  2.  
  3. $user=$_SESSION["id_user"];
  4. $id=$_POST["id"];
  5. $fecha_i=$_POST["start"];
  6. $fecha_f=$_POST["end"];
  7. $interv1=$_POST["interv1"];
  8. $interv2=$_POST["interv2"];
  9.  
  10. function minutos_transcurridos($fecha_i,$fecha_f){
  11.     $minutos = (strtotime($fecha_i)-strtotime($fecha_f))/60;
  12.     $minutos = abs($minutos); $minutos = floor($minutos);
  13.     return $minutos;
  14. }
  15.  
  16. $sql1="select id_usuario,start,end from turnos_toma
  17. where start='".$fecha_i."' and end='".$fecha_f."' and id_usuario=".$user." limit 1";
  18. $res1=mysqli_query($conexion,$sql1);
  19. $num1=mysqli_num_rows($res1);
  20.     if ($num1!="0") {
  21.         echo "Ya tomaste este turno!";exit;
  22.     }else{
  23.  
  24.     $sql2="SELECT count(id) as cantidad from turnos_toma
  25.     where start BETWEEN '".$interv1."'  AND '".$interv2."' and id_usuario=".$user."";                                  
  26.     $res2=mysqli_query($conexion,$sql2);
  27.     $count2 = mysqli_fetch_array($res2);
  28.         if ($count2[0]==4) {
  29.             echo "No puedes tomar más de 4 turnos.";exit;
  30.         }else{             
  31.  
  32.             $sql3="select start from turnos_toma where
  33.             start BETWEEN '".$interv1."'  AND '".$interv2."' and
  34.             id_usuario=".$_SESSION["id_user"]."";
  35.             $res3=mysqli_query($conexion,$sql3);
  36.             $num3 = mysqli_num_rows($res3);
  37.                 if ($num3==0) {
  38.                     $sql4="update turnos_asignacion set cantidad=cantidad-1 where id=".$id."";
  39.                     $res4=mysqli_query($conexion,$sql4);
  40.                     $sql5="insert into turnos_toma values(null,".$id.",".$user.",'".$fecha_i."','".$fecha_f."')";
  41.                     $res5=mysqli_query($conexion,$sql5);
  42.                     echo "Turno tomado con éxito";exit;
  43.                 }else{
  44.  
  45.                     while ($row3=mysqli_fetch_array($res3)) {  
  46.                         if (minutos_transcurridos($row3["start"],$fecha_i)<210) {
  47.                             echo "No puedes tomar este turno.";exit;
  48.                         }
  49.                     }      
  50.                    
  51.                     $sql6="update turnos_asignacion set cantidad=cantidad-1 where id=".$id."";
  52.                     $res6=mysqli_query($conexion,$sql6);
  53.                     $sql7="insert into turnos_toma values(null,".$id.",".$user.",'".$fecha_i."','".$fecha_f."')";
  54.                     $res7=mysqli_query($conexion,$sql7);
  55.                     echo "Turno tomado con éxito";exit;
  56.                 }
  57.            }
  58.     }
  59.  
  60. mysqli_close($conexion);