Ver Mensaje Individual
  #4 (permalink)  
Antiguo 23/05/2006, 08:52
morpheux
 
Fecha de Ingreso: abril-2006
Mensajes: 14
Antigüedad: 18 años
Puntos: 0
Código PHP:
function push()
{
        
session_start();
        global 
$_CONT_BUTACAS$_BUTACAS$_SALA,$_HORA,$_FECHA,$_USUARIO,$_CINE;
        
//$arr_but=array();
        
$contenido="";
        if (
$_SESSION['_CONT_BUTACAS'] < 9)
        {
            
$rep 0;
            for (
$i=0;$i<count($_SESSION['_BUTACAS']);$i++)
            {
                if (
$_SESSION['_BUTACAS'][$i]==$_REQUEST['id'])
                {
                    
$rep=1;
                }
            }
            if (
$rep == 0)
            {
                
$link=conectadb();
                
$pos=0;
                for (
$q=0;$q<count($_SESSION['_BUTACAS']);$q++)
                {
                    
$pos=$q;
                }
                
$_SESSION['_BUTACAS'][$pos+1]=$_REQUEST['id'];
                
$_SESSION['_CONT_BUTACAS']= $_CONT_BUTACAS 1;
                
$_SESSION['_SALA']=$_REQUEST['sala'];
                
$_SESSION['_HORA']=$_REQUEST['hora'];
                
$_SESSION['_FECHA']=date("dmY");
                
$_SESSION['_USUARIO']=$_REQUEST['user'];
                
$_SESSION['_CINE']=$_REQUEST['cine'];
                
$sql="select * from prc_butaca where id_sala=".$_SESSION['_SALA'];
                
$res=mysql_query($sql,$link) or die("<html>
                                                <head>
                                                <meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">
                                                <link href=\"estilo.css\" rel=\"stylesheet\" type=\"text/css\">
                                                </head>
                                                    <body>
                                                    <br><br><br><br>
                                                    <table width=\"800\" border=\"0\" align=\"center\" cellpadding=\"3\" cellspacing=\"3\" class=\"tableb\">
                                                    <tr><td>
                                                    <h3 align=\"center\">No se pudo completar la operación:"
.mysql_error()."<br></h3>
                                                    <h3 align=\"center\">No se puedo completar la operación:"
.$sql."<br></h3>
                                                    
                                                    </td></tr></table>
                                                </body>
                                            </html>"
);
                
$arr_but = array();
                while (
$but mysql_fetch_array($res,MYSQL_ASSOC))
                {
                    
$arr_but[]=$but['id'];
                }
                
$sql="select * from prc_sala where id=".$_SESSION['_SALA'];
                
$resala=mysql_query($sql,$link) or die("<html>
                        <head>
                        <meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">
                        <link href=\"estilo.css\" rel=\"stylesheet\" type=\"text/css\">
                        </head>
                            <body>
                            <br><br><br><br>
                            <table width=\"800\" border=\"0\" align=\"center\" cellpadding=\"3\" cellspacing=\"3\" class=\"tableb\">
                            <tr><td>
                            <h3 align=\"center\">No se pudo completar la operación:"
.mysql_error()."<br></h3>
                            <h3 align=\"center\">No se puedo completar la operación:"
.$sql."<br></h3>
                            </td></tr></table>
                        </body>
                    </html>"
);
                
$dat_sala=mysql_fetch_array($resala,MYSQL_ASSOC);
                
$filas=$dat_sala['fila'];
                
$columnas=$dat_sala['columna'];
                
$contenido .="<html>
                            <head>
                            <title>Documento sin t&iacute;tulo</title>
                            <meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">
                            <link href=\"estilo.css\" rel=\"stylesheet\" type=\"text/css\">
                            </head>
                            
                            <body>
                            <table width=\"400\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\" class=\"tableb\">
                              <tr>
                                <td>"
;
                
$contenido .="<div style=\"padding-top:20px; padding-left:20px; padding-right:20px; padding-bottom:20px; background-color:#FFFFFF\">
                            <p align=\"center\" style=\"font-family:'Trebuchet MS', Verdana, Tahoma; font-size:10px; font-weight:bold; color:#000000\">Hoy::::Mañana::::Pasado Mañana &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{HORAS}</p>
                        </div>
                            <div style=\"padding-top:20px; padding-left:20px; padding-right:20px; padding-bottom:20px; background-color:#FFFFFF\"><table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"
;
                
$butid=reset($arr_but);
                for (
$i=1;$i<=$filas;$i++)
                {
                  
$contenido.="<tr>";
                    for(
$x=1;$x<=$columnas;$x++)
                     {
                        
$butid=current($arr_but);
                        
$sql="select * from prc_compran where id_butaca=".$butid." AND fecha= ".$_SESSION['_FECHA']." AND hora=".$_SESSION['_HORA'];
                        
$res=mysql_query($sql,$link) or die("<html>
                                                                <head>
                                                                <meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">
                                                                <link href=\"estilo.css\" rel=\"stylesheet\" type=\"text/css\">
                                                                </head>
                                                                    <body>
                                                                    <br><br><br><br>
                                                                    <table width=\"800\" border=\"0\" align=\"center\" cellpadding=\"3\" cellspacing=\"3\" class=\"tableb\">
                                                                    <tr><td>
                                                                    <h3 align=\"center\">No se pudo completar la operación:"
.mysql_error()."<br></h3>
                                                                    <h3 align=\"center\">No se puedo completar la operación:"
.$sql."<br></h3>
                                                                    </td></tr></table>
                                                                </body>
                                                            </html>"
);
                        
// recorremos aqui todo el array de las butacas, y comprobamos que alguno de ellos no sea igual que la butaca que tenemos ahora en butid, si es asi
                        // en la parte del if diferenciaremos entre libre y por el usuario, si la variable esta a 0 tal y sino pascual
                        
$bingo=0;
                        
$aux=$butid;
                        for (
$m=1;$m<=count($_SESSION['_BUTACAS']);$m++)
                        {
                            
//echo ($_BUTACAS[$m]. " == " . $butid." - ". $_REQUEST['id'] );
                            
if ($_SESSION['_BUTACAS'][$m]==$aux)
                            {
                                
$bingo=1;
                            }
                        }
                        
//die($aux. " - ". $_BUTACAS[$m]);
                        //die("FIN");
                        
if (!mysql_num_rows($res))
                        {    
                                if (
$bingo==1)
                                {    
                                    echo 
$_SESSION['_CONT_BUTACAS'];
                                    
$contenido.= "<td width=\"32\" height=\"30px\"><a href=\"comprar.php?id=".$butid."&cine=".$_SESSION['_CINE']."&sala=".$_SESSION['_SALA']."&hora=".$_SESSION['_HORA']."&acc=2&user=".$_SESSION['_USUARIO']."\"><img src=\"imagenes/butaca_usu.jpg\" border=\"0\"></a></td>";
                                }
                                else
                                {
                                    
$contenido.= "<td width=\"32\" height=\"30px\"><a href=\"comprar.php?id=".$butid."&cine=".$_SESSION['_CINE']."&sala=".$_SESSION['_SALA']."&hora=".$_SESSION['_HORA']."&acc=1&user=".$_SESSION['_USUARIO']."\"><img src=\"imagenes/butaca_libre.jpg\" border=\"0\"></a></td>";
                                }
                        }
                        else
                        {
                                
$contenido.= "<td width=\"32\" height=\"30px\"><img src=\"imagenes/butaca_ocu.jpg\" border=\"0\"></td>";
    
                        }
                        
next($arr_but);
                     }
                  
$contenido.="</tr>";
                }        
              
            
$contenido.="</table>
            <a>Continuar</a>
            </div>
            </td>
              </tr>
            </table>
            </body>
            </html>"
;
            echo 
$contenido;    
            }
            else
            {
                
            }
        }
        else
        {
        }

Lo he cambiado todo como me has indicaddo, y me siguen sin funcionar las variables de session cuando vuelvo a llamar al script, es decir que solo me incluye un elemento en el array, y que el contador siempre marca 1



Alguna ayudita

Muchas gracias