• Domingo 19 de Mayo de 2024, 08:12

Autor Tema:  Puedo Crear Una Funcion Que Solo Devulva Un Valor  (Leído 1535 veces)

neorent

  • Miembro MUY activo
  • ***
  • Mensajes: 249
    • Ver Perfil
    • http://www.laestokada.cl
Puedo Crear Una Funcion Que Solo Devulva Un Valor
« en: Jueves 21 de Septiembre de 2006, 22:08 »
0
bueno espero que poder explicarme, miren estoy haciendo una funcion donde solo necesito que me devuleva un valor osea yo le pido un valor, se puede hacer, bueno si yo tengo una variable donde quiero que reciba el valor de la funcion llamada como puedria hacerlo, bueno les presento el code y ustedes me dicen que cambio bueno gracias chicos.

Código: Text
  1.  
  2. ///aqui es donde esta la funcion  myfunc.php///////
  3. <?php
  4. function hora_salida_edificio($hora1){
  5. $link = mysql_connect("localhost", "root", "");
  6. mysql_select_db("db_soporte", $link);
  7. $sql = "SELECT * FROM tbl_edificio WHERE (des_edificio = '$i_edificio')";
  8. $result = mysql_query($sql, $link);                    
  9. $myrow = mysql_fetch_array($result);
  10. $hora1=$myrow["tiempo"];
  11. return $hora1;
  12. }
  13.  
  14.  
Código: Text
  1.  
  2. ///aqui es donde llamo la funcion y es donde necesito recibir el resultado///
  3. <?php
  4. include("conex.php");
  5. include("myfunc.php");
  6. $tiempo=hora_salida_edificio($hora1);
  7. echo $tiempo;
  8. ?>
  9.  
  10.  
Un Tigre Nunka Kambia Sus Rayas

ArKaNtOs

  • Miembro de PLATA
  • *****
  • Mensajes: 1253
  • Nacionalidad: mx
    • Ver Perfil
Re: Puedo Crear Una Funcion Que Solo Devulva Un Valor
« Respuesta #1 en: Jueves 21 de Septiembre de 2006, 22:17 »
0
pero que pasa, te marca algun error o que pasa con ese code :)

neorent

  • Miembro MUY activo
  • ***
  • Mensajes: 249
    • Ver Perfil
    • http://www.laestokada.cl
Re: Puedo Crear Una Funcion Que Solo Devulva Un Valor
« Respuesta #2 en: Jueves 21 de Septiembre de 2006, 22:50 »
0
bueno no se si me da un error lo que pasa es que estoy trantando de ordenar el codigo, pk esta muy desordenado y ademas esta todo junto, y bueno me graba pero al momento de hacer un actualizacion o presionar f5 me actualiza la pagina y si estabagrabando algo y me da un resultado el me lo aumenta osea si mi numero unico era 1 al momento de grabar al presionar F5 me pasa al numero 2 y no quiero que haga eso por eso estaba tratando de separar el code pero no me funka ya que hay varias consultas en la misma linea y con valores que vienen de un post entonces es mucho agetreo estar pasando los valores, si quieres te muestro el code y veras que lo que digo es cierto jejejeje, bueno te dejo el ingreso y donde lo grabo y veras que se crea uno nuevo ahora si sabes como evitar que al momento de presionar F5 o actualizar no me envie a la misma pagina sino que me envie diractamente a otra seria genial, pero no se como hacerlo jejejej

Código: Text
  1.  
  2. ////ingreso_db.php//////
  3. <html>
  4. <head>
  5.    <title>Ingreso Solicitud</title>
  6. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  7. <style type="text/css">
  8. <!--
  9. .Estilo1 {color: #00CCFF}
  10. -->
  11. </style>
  12. </head>
  13. <body bgcolor="#14285f">
  14. <body>
  15. <p>
  16. </p>
  17.   <?php include("formato.php"); ?>
  18.   <?php CabeceraPagina(); ?>
  19. <h3 align="center" class="Estilo1">  INGRESO DE SOLICITUDES </h3>
  20. <FORM ACTION="muestrafolio.php">
  21. <TABLE>
  22. <TR>
  23.    <TD width="129">NOMBRE SOLICITANTE: </TD>
  24.    <TD width="428"><INPUT NAME="nombre" TYPE="text" id="nombre" tabindex="1" SIZE="50" MAXLENGTH="100"></TD>
  25. </TR>
  26. <TR>
  27.   <TD>AREA:</TD>
  28.   <TD><?php
  29.   $link=mysql_connect("localhost","root", "");
  30.   $link1=mysql_select_db("db_soporte",$link);
  31.   $result=mysql_query("select * from tbl_area ORDER BY `id_area` ASC ");
  32.   echo '<select name="area" tabindex="2">';
  33.   //Generamos el menu desplegable
  34.   while ($row=mysql_fetch_array($result))
  35.   {echo '<option>'.$row["des_area"];}
  36.   echo "</select>";
  37.   mysql_free_result($result);
  38.   ?>
  39.   </TD>
  40. </TR>
  41. <TR>
  42.   <TD>DIRECCION: </TD>
  43.   <TD><?php
  44.   $link=mysql_connect("localhost","root", "");
  45.   $link1=mysql_select_db("db_soporte",$link);
  46.   $result=mysql_query("select * from tbl_direcciones ORDER BY `id_area2` ASC ");
  47.   echo '<select name="direccion"tabindex="3"readonly="true">';
  48.   //Generamos el menu desplegable
  49.   while ($row=mysql_fetch_array($result))
  50.   {echo '<option>'.$row["des_direccion"];}
  51.   echo "</select>";
  52.   mysql_free_result($result);?></TD>
  53. </TR>
  54. <TR>
  55.   <TD>UNIDAD / DEPTO. </TD>
  56.   <TD><?php
  57.   $link=mysql_connect("localhost","root", "");
  58.   $link1=mysql_select_db("db_soporte",$link);
  59.   $result=mysql_query("select * from tbl_unidades ORDER BY `id_unidad` ASC ");
  60.   echo '<select name="unidad"tabindex="4">';
  61.   //Generamos el menu desplegable
  62.   while ($row=mysql_fetch_array($result))
  63.   {echo '<option>'.$row["des_unidad"];}
  64.   echo "</select>";
  65.   mysql_free_result($result);
  66.   ?></TD>
  67. </TR>
  68. <TR>
  69.   <TD>EDIFICIO</TD>
  70.   <TD>
  71.     <?php
  72.   $link=mysql_connect("localhost","root", "");
  73.   $link1=mysql_select_db("db_soporte",$link);
  74.   $result=mysql_query("select * from tbl_edificio ORDER BY `id_edificio` ASC ");
  75.   echo '<select name="edificio" tabindex="5">';
  76.   //Generamos el menu desplegable
  77.   while ($row=mysql_fetch_array($result))
  78.   {echo '<option>'.$row["des_edificio"];}
  79.   echo "</select>";
  80.   mysql_free_result($result);
  81.   ?></TD>
  82. </TR>
  83. <TR>
  84.   <TD>PISO:</TD>
  85.   <TD><?php
  86.   $link=mysql_connect("localhost","root", "");
  87.   $link1=mysql_select_db("db_soporte",$link);
  88.   $result=mysql_query("select * from tbl_pisos ORDER BY `id_piso` ASC ");
  89.   echo '<select name="piso" tabindex="6">';
  90.   //Generamos el menu desplegable
  91.   while ($row=mysql_fetch_array($result))
  92.   {echo '<option>'.$row["des_piso"];}
  93.   echo "</select>";
  94.   mysql_free_result($result);
  95.   ?></TD>
  96. </TR>
  97. <TR>
  98.   <TD>CORREO ELECTRONICO: </TD>
  99.   <TD><input name="correo" type="text" id="correo" tabindex="7" size="20" maxlength="30"></TD>
  100. </TR>
  101. <TR>
  102.   <TD>TIPO REQUERIMIENTO  :</TD>
  103.   <TD><?php
  104.   $link=mysql_connect("localhost","root", "");
  105.   $link1=mysql_select_db("db_soporte",$link);
  106.   $result=mysql_query("select * from tbl_fallas ORDER BY `id_falla` ASC ");
  107.   echo '<select name="requerimiento" tabindex="8">';
  108.   //Generamos el menu desplegable
  109.   while ($row=mysql_fetch_array($result))
  110.   {echo '<option>'.$row["desc_falla"];}
  111.   echo "</select>";
  112.   mysql_free_result($result);
  113.   ?></TD>
  114. </TR>
  115. <TR>
  116.   <TD>FONO / ANEXO : </TD>
  117.   <TD><input name="fono" type="text" id="fono" tabindex="9" size="10" maxlength="10"></TD>
  118. </TR>
  119. <TR>
  120.   <TD>FECHA SOLICITUD : </TD>
  121.   <TD><input name="fecha" type="text"  id="fecha" tabindex="10" value="<?php echo date("d/m/Y")?>" readonly="true"></TD>
  122. </TR>
  123. <TR>
  124.   <TD>HORA SOLICITUD :</TD>
  125.   <TD><input name="hora" type="text" id="hora" tabindex="11" value="<?php echo date("H:i:s")?>" readonly="true"></TD>
  126. </TR>
  127. </TABLE>
  128. <input type="submit" name="save" value="Grabar">
  129. </FORM>
  130. <?php PiePagina(); ?>
  131. </body>
  132. </html>
  133.  
  134.  
y en este es donde almaceno y muestro y cuando presiono F5 me pasa lo que mencionaba anteriormente.
Código: Text
  1.  
  2. ///muestrafolio.php//////
  3. <?php
  4. include("conex.php");  
  5. include("myfunc.php");                        
  6. $link=Conectarse();                          
  7. $i_nombre=$_GET['nombre'];                          
  8. $i_area=$_GET['area'];                        
  9. $i_direcc=$_GET['direccion'];    
  10. $i_unidad=$_GET['unidad'];    
  11. $i_edificio=$_GET['edificio'];      
  12. $i_piso=$_GET['piso'];      
  13. $i_correo=$_GET['correo'];        
  14. $i_fono=$_GET['fono'];
  15. $i_requerimiento=$_GET['requerimiento'];
  16. $i_fecha=cambiaf_a_mysql($_GET['fecha']);          
  17. $i_hora=$_GET['hora'];          
  18. mysql_query("insert into tbl_maestra (nombre_usuario,area_usuario,direccion_usuario,depto_usuario,edificio,piso,correo_usuario,fono_anexo,tipo_requerimiento,fecha_solicitud,hora_solicitud) values ('$i_nombre','$i_area','$i_direcc','$i_unidad','$i_edificio','$i_piso','$i_correo','$i_fono','$i_requerimiento','$i_fecha','$i_hora')",$link);        
  19. $ultimo_id = mysql_insert_id($link);
  20. ?>
  21. <?php
  22. $link = mysql_connect("localhost", "root", "");              
  23. mysql_select_db("db_soporte", $link);                    
  24. $sql = "SELECT * FROM tbl_edificio WHERE (des_edificio = '$i_edificio')";    
  25. $result = mysql_query($sql, $link);                    
  26. $myrow = mysql_fetch_array($result);                  
  27. $hora1=$myrow["tiempo"];                      
  28. $hora2=$myrow["tiempo"];                      
  29. $link = mysql_connect("localhost", "root", "");              
  30. mysql_select_db("db_soporte", $link);                    
  31. $sql = "SELECT * FROM tbl_fallas WHERE (desc_falla = '$i_requerimiento')";    
  32. $result = mysql_query($sql, $link);                    
  33. $myrow = mysql_fetch_array($result);                
  34. $hora3=$myrow["t_trabajo"];                      
  35. $horades1=explode(':', $hora1);                      
  36. $horades2=explode(':', $hora2);                      
  37. $horades3=explode(':', $hora3);                      
  38. $finalh=$horades1[0] + $horades2[0] + $horades3[0];            
  39. $finalm=$horades1[1] + $horades2[1] + $horades3[1];            
  40. $finals=$horades1[2] + $horades2[2] + $horades3[2];            
  41. if ($finals>59){                          
  42. $finals=$finals - 60;                          
  43. $finalm=$finalm + 1;                        
  44. }                                
  45. if ($finalm>59){
  46. $finalm=$finalm - 60;
  47. $finalh=$finalh + 1;
  48. }
  49. if (strlen($finalh)==1){
  50. $finalh= "0".$finalh;
  51. }
  52. if (strlen($finalm)==1){
  53. $finalm= "0".$finalm;
  54. }
  55. if (strlen($finals)==1){
  56. $finals= "0".$finals;
  57. }
  58. $final_horas = $finalh.":".$finalm.":".$finals;
  59. mysql_query("insert into tbl_temporal (folio,id_unidad,id_edificio,t_trabajo,total_trabajo) values ('$ultimo_id','$i_unidad','$hora1,'$hora3','$final_horas')",$link);  
  60. ?>
  61. <title>RESULTADO DE SOLICITUD</title>
  62. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  63. <link rel="stylesheet" href="mm_entertainment.css" type="text/css" />
  64. </head>
  65. <body bgcolor="#14285f">
  66. <table width="100%" border="0" cellspacing="0" cellpadding="0">
  67.   <tr bgcolor="02021e">
  68.     <td width="400" colspan="2" rowspan="2" nowrap="nowrap"><img src="Imagenes/bannerSoporte.jpg" alt="Header image" width="468" height="60" border="0" /></td>
  69.     <td width="360" height="58" nowrap="nowrap" id="logo" valign="bottom">NOMBRE DEL SITIO WEB</td>
  70.     <td width="100%"> </td>
  71.   </tr>
  72.   <tr bgcolor="02021E">
  73. <td height="57" nowrap="nowrap" id="tagline" valign="top">Lema opcional</td>
  74.  
  75.  
  76.   <td width="100%"> </td>
  77.   </tr>
  78.   <tr>
  79.     <td colspan="4" bgcolor="#cc3300"><img src="Imagenes/mm_spacer.gif" alt="" width="1" height="2" border="0" /></td>
  80.   </tr>
  81.  
  82.    <tr>
  83.     <td colspan="4"><img src="Imagenes/mm_spacer.gif" alt="" width="1" height="2" border="0" /></td>
  84.   </tr>
  85.  
  86.    <tr>
  87.     <td colspan="4" bgcolor="#cc3300"><img src="Imagenes/mm_spacer.gif" alt="" width="1" height="1" border="0" /></td>
  88.   </tr>
  89.    <tr>
  90.     <td colspan="5" id="dateformat"> <br />
  91.       <a href="menu.php">VOLVER AL MENU PRINCIPAL </a><br />  </td>
  92.   </tr>
  93.   <tr>
  94.     <td width="50" valign="top"> </td>
  95.    <td colspan="2" valign="top"><br />
  96.   <table border="0" cellspacing="0" cellpadding="2" width="610">
  97.         <tr>
  98. <td class="subHeader" colspan="3"><p style="margin-top: 0; margin-bottom: 0;">DETALLE DE REQUERIMIENTO </p>          </td>
  99.         </tr>
  100.         <tr>
  101.           <td width="282" height="250" rowspan="2" align="center" class="subHeader"><img src="Imagenes/soporte-tecnico.jpg" alt="" width="264" height="264" border="0" /></td>
  102.           <td width="23" rowspan="2"> </td>
  103.           <td width="293" class="sidebarHeader">Requerimiento Solicitado <br />
  104.       <br />          </td>
  105.         </tr>
  106.  
  107.         <tr>
  108.           <td valign="top" class="bodyText"><p>Su Nº de Requerimiento es:
  109.               <input name="folio" type="text" id="folio" value="<?php echo $ultimo_id ?>" readonly="true"/>
  110. </p>
  111.             <p>El Tecnico Asignado es:</p>
  112.             <p>
  113.               <input name="tecnico" type="text" id="tecnico" readonly="true" />
  114.             </p>
  115.             <p>Su tiempo de espera es de:</p>
  116.             <p>
  117.               <input name="tiempo" type="text" id="tiempo" value="<?php echo $final_horas?>" readonly="true">
  118.               . </p></td>
  119.         </tr>
  120.       </table>    
  121.   </td>
  122.     <td> </td>
  123.   </tr>
  124.   <tr>
  125.     <td width="50"> </td>
  126.     <td width="350"> </td>
  127.     <td width="360"> </td>
  128.   <td width="100%"> </td>
  129.   </tr>
  130. </table>
  131. <br />
  132. </body>
  133. </html>
  134.  
  135.  
si ustedes prueban el code funciona bien y graba pero si presionan F5 se repite la informacion y aumenta el contador unico y eso es lo que no quiero bueno si alguien sabe como lo puedo se los agradeceria muchisimo adios mis amigos
Un Tigre Nunka Kambia Sus Rayas

ArKaNtOs

  • Miembro de PLATA
  • *****
  • Mensajes: 1253
  • Nacionalidad: mx
    • Ver Perfil
Re: Puedo Crear Una Funcion Que Solo Devulva Un Valor
« Respuesta #3 en: Jueves 21 de Septiembre de 2006, 22:53 »
0
ups esa misma duda acabo de postear, no se como evitar el problema del actualizar :P pero lo estoy inverstigando :)

neorent

  • Miembro MUY activo
  • ***
  • Mensajes: 249
    • Ver Perfil
    • http://www.laestokada.cl
Re: Puedo Crear Una Funcion Que Solo Devulva Un Valor
« Respuesta #4 en: Jueves 21 de Septiembre de 2006, 22:58 »
0
sip lo acabo de ver jejeje bueno estoy buscando en la web cualquier cosa la posteo aqui y en el tuyo ok gracias amigo
Un Tigre Nunka Kambia Sus Rayas

ArKaNtOs

  • Miembro de PLATA
  • *****
  • Mensajes: 1253
  • Nacionalidad: mx
    • Ver Perfil
Re: Puedo Crear Una Funcion Que Solo Devulva Un Valor
« Respuesta #5 en: Jueves 21 de Septiembre de 2006, 23:10 »
0
ya esta resuelto :P mas bien nos fallo la logica jejeje

neorent

  • Miembro MUY activo
  • ***
  • Mensajes: 249
    • Ver Perfil
    • http://www.laestokada.cl
Re: Puedo Crear Una Funcion Que Solo Devulva Un Valor
« Respuesta #6 en: Viernes 22 de Septiembre de 2006, 16:52 »
0
sorry amigo pero no entendi me podrias explicar te lo agradeceria mucho adios amigos
Un Tigre Nunka Kambia Sus Rayas