Ver Mensaje Individual
  #3 (permalink)  
Antiguo 05/05/2006, 12:17
Avatar de 8461277
8461277
 
Fecha de Ingreso: diciembre-2002
Ubicación: san juan de los morros
Mensajes: 887
Antigüedad: 21 años, 4 meses
Puntos: 1
Lo acabo de colocar y no me funciona todavia: aqui esta codigo:

Código PHP:
<html>
<head>
<title>Untitled Document</title>

<script type="text/javascript">
<!--

function buscar()
{
   var F=document.forms["prestamo"];
     F.submit();
}

// -->
</script>

</head>
<body bgcolor="#FFFFFF">
<?php

include "conexion.php";
include 
"fecha.php";
$cota=$_POST[$cota];//[B]aqui esta deficion de la variable cota[/B]
$num_cota 0;
if (isset(
$cota))
{
     
$sql "select * from documento where cota = '$cota'";
   
$cursor mysql_query($sql);
     echo 
mysql_error();
     
$num_cota mysql_num_rows($cursor);
     
     if (
$num_cota
     {
         
$ejemplares mysql_result($cursor,0,"nro_ejem");             
             
$sql "select count(*) as total from prestamo where cota  = '$cota'"
         
$cursor1 mysql_query($sql);
             
$ejemp_prestados =  mysql_result($cursor1,0,"total");
             
//echo "ejemplares = $ejemplares <br> Ejemplares prestados = $ejemp_prestados";
             
if ($ejemplares == $ejemp_prestados)
              {
?>
<script language="JavaScript" type="text/javascript">
             <!--
                           cota = '<?php echo $cota?>'
               alert('Todos los ejemplares pertenecientes a la cota '+cota+' ya fueron prestados')
             //-->
           </script>               
<?php
        $cota 
"";  
                }
             else
              
$titulo mysql_result($cursor,0,"titulo");
     }      
}

$num_cedula 0;
if (isset(
$cedula))
{
     
$sql "select * from usuario where cedula = '$cedula'";
     
   
$cursor mysql_query($sql);
     
     
$num_cedula mysql_num_rows($cursor);
     
     if (
$num_cedula
     {
        
$sql "select * from prestamo where cedula = '$cedula' and cota = '$cota'";          
            
$cursor1 mysql_query($sql);
            
$num mysql_num_rows($cursor1);            
            if (
$num)
             {
?>
          <script language="JavaScript" type="text/javascript">
             <!--
                           cota = '<?php echo $cota?>'
               cedula = '<?php echo $cedula ?>'
                             alert('El usuario con número de cédula '+cedula+' ya realizó un prestamo con la cota '+cota)
             //-->                         
           </script>
<?php             
         $cedula 
"";
             }
            else
             { 
               
$usuario mysql_result($cursor,0,"apellido");
               
$usuario .= ", "mysql_result($cursor,0,"nombre");
         }
     } 
          
}

if (!isset(
$btn_prestar))
{
 
?>

<form name="prestamo" method="post" action="prestamo.php">
  <table width="600px" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td>
        <table align="center" width="309">
          <tr bgcolor="#FF9933" valign="middle"> 
            <td colspan="2" height="14" align="center"> 
              <h1><font face="Arial, Helvetica, sans-serif"><font face="Arial, Helvetica, sans-serif"><font size="4"><font size="4"><font color="#FFFFFF">PRESTAMO</font></font></font></font></font></h1>
            </td>
          </tr>
          <tr> 
            <td bgcolor="#FFD7C4" width="174"> 
              <p><font face="Arial, Helvetica, sans-serif" size="1">Cota del Documento</font></p>
            </td>
            <td width="130"> 
              <input type="text" name="cota" value = "<?php echo $cota ?>" onBlur="buscar()">
            </td>
          </tr>
          <?php if ($num_cota) { ?>
          <tr> 
            <td bgcolor="#FFD7C4" width="174"> 
              <p><font face="Arial, Helvetica, sans-serif" size="1">Título del 
                Documento:</font></p>
            </td>
            <td width="130" > 
              <?php echo $titulo?>
            </td>
          </tr>
          <?php ?>
          <tr> 
            <td bgcolor="#FFD7C4" width="174"> 
              <p><font face="Arial, Helvetica, sans-serif" size="1">Cédula del 
                Usuario</font></p>
            </td>
            <td width="130"> 
              <input type="text" name="cedula" value = "<?php echo $cedula ?>" onBlur="buscar()">
            </td>
          </tr>
          <?php if ($num_cedula) { ?>
          <tr> 
            <td bgcolor="#FFD7C4" width="174"> 
              <p><font face="Arial, Helvetica, sans-serif" size="1">Apellido y 
                Nombre del usuario:</font></p>
            </td>
            <td width="130" > 
              <?php echo $usuario?>
            </td>
          </tr>
          <?php } else { ?>
          <tr> 
            <td bgcolor="#FFD7C4" width="174"> 
              <p><font face="Arial, Helvetica, sans-serif" size="1">Apellidos</font></p>
            </td>
            <td width="130"> 
              <input type="text" name="apellido">
            </td>
          </tr>
          <tr> 
            <td bgcolor="#FFD7C4" width="174"> 
              <p><font face="Arial, Helvetica, sans-serif" size="1">Nombres</font></p>
            </td>
            <td width="130"> 
              <input type="text" name="nombre">
            </td>
          </tr>
          <?php ?>
          <tr> 
            <td bgcolor="#FFD7C4" width="174"> 
              <p><font face="Arial, Helvetica, sans-serif" size="1">Fecha de Préstamo</font></p>
            </td>
            <td width="130"> 
              <?php 
                   $fecha_prestamo 
date("d-m-Y");
                   echo 
$fecha_prestamo;
                
?>
              <input type = "hidden" name = "fecha_prestamo" value = "<?php echo $fecha_prestamo ?>">
            </td>
          </tr>
          <tr> 
            <td bgcolor="#FFD7C4" width="174"> 
              <p><font face="Arial, Helvetica, sans-serif" size="1">Días de Préstamos</font></p>
            </td>
            <td width="130"> 
              <input type="text" name="dias_prestamo">
            </td>
          </tr>
          <tr align="center"> 
            <td colspan="3" height="61"> 
              <input type="submit" name="btn_prestar" value="Prestar">
              <br>
              <hr aling="center">
            </td>
          </tr>
        </table>
      </td>
    </tr>
  </table>
  
  </form>

<?php
}
else
{
   echo 
"prestar";
     
     if (
$cedula == 0)
       {
         
       echo 
"El usuario con número de cédula $cedula ya realizó un prestamo con la cota $cota<br>".
                      
"El prestamo fue cancelado";       
          return;
         }
     
     
$sql "select * from usuario where cedula = '$cedula'";
   
$cursor mysql_query($sql);
     
$num_cedula mysql_num_rows($cursor);
     
     
     if (!
$num_cedula)
     {
        
$sql "insert into usuario (cedula,nombre,apellido)".
                   
" values ('$cedula','$nombre','$apellido')";
            
mysql_query($sql);
     }
     
     
$sql "insert into prestamo (cota,cedula,fecha_prestamo,dias_prestamo)".
            
" values ('$cota','$cedula','".invfecha($fecha_prestamo)."','$dias_prestamo')";
     
mysql_query($sql);


?>

</body>
</html>
Ayudeme porfa
__________________
Miguel Padrón :cool: