elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Tutorial básico de Quickjs


  Mostrar Temas
Páginas: [1]
1  Programación / PHP / No me muestra resultados Paginador PHP,MYSQL en: 25 Noviembre 2014, 16:08 pm
Estoy implementando este sencillo  paginador, me funciono bn pero cuando trate de hacerlo con PDO no me muestra los valores pero si muestra cuantos resultados se trajeron, estoy probando pero no me funciona, espero me puedan colaborar

Gracias :cool:

Código
  1. <html>
  2. <head>
  3. <title>ShotDev.Com Tutorial</title>
  4. </head>
  5. <body>
  6. <?php
  7. $db_username = "";
  8. $db_password = "";
  9. $db = "oci:dbname=";
  10. //$conn = new PDO($db,$db_username,$db_password);
  11.  
  12. try{
  13.    $conn = new PDO($db,$db_username,$db_password);
  14.    echo "conectado correctamente";
  15. }catch(PDOException $e){
  16.    echo ($e->getMessage());
  17.    echo "<br>Error Conection";
  18. }
  19.    $st=$conn->prepare("SELECT PD_ID, PD_CANTIDAD, PRODUCTOS_PRO_ID, DEVOLUCION_MM_DMM_ID FROM PRODUCTO_DEVOLUCION ORDER BY PD_ID ASC");
  20.    $st->execute( );
  21.    $Result=$st->fetchAll($Result);
  22.  
  23.     foreach ($Result as $Result1) :
  24.       $a=$Result1['PD_ID'];          
  25.     endforeach;
  26.  
  27.    $Num_Rows=$Result;
  28.  
  29.    $Num_Rows=count($Num_Rows);
  30.  
  31.  
  32.  
  33.  
  34. $Per_Page = 2;   // Per Page
  35.  
  36. $Page = $_GET["Page"];
  37. if(!$_GET["Page"])
  38. {
  39. $Page=1;
  40. }
  41.  
  42. $Prev_Page = $Page-1;
  43. $Next_Page = $Page+1;
  44.  
  45. $Page_Start = (($Per_Page*$Page)-$Per_Page);
  46. if($Num_Rows<=$Per_Page)
  47. {
  48. $Num_Pages =1;
  49. }
  50. else if(($Num_Rows % $Per_Page)==0)
  51. {
  52. $Num_Pages =($Num_Rows/$Per_Page) ;
  53. }
  54. else
  55. {
  56. $Num_Pages =($Num_Rows/$Per_Page)+1;
  57. $Num_Pages = (int)$Num_Pages;
  58. }
  59. $Page_End = $Per_Page * $Page;
  60. if ($Page_End > $Num_Rows)
  61. {
  62. $Page_End = $Num_Rows;
  63. }
  64.  
  65. ?>
  66. <table width="600" border="1">
  67.  <tr>
  68.    <th width="91"> <div align="center">CustomerID </div></th>
  69.    <th width="98"> <div align="center">Name </div></th>
  70.    <th width="198"> <div align="center">Email </div></th>
  71.    <th width="97"> <div align="center">CountryCode </div></th>
  72.  
  73.  </tr>
  74. <?php
  75. for($i=$Page_Start;$i<$Page_End;$i++)
  76. {
  77. ?>
  78.  <tr>
  79.    <td><div align="center"><?php echo $Result["PD_ID"][$i];?></div></td>
  80.    <td><?php echo $Result["PD_CANTIDAD"][$i];?></td>
  81.    <td><?php echo $Result["PRODUCTOS_PRO_ID"][$i];?></td>
  82.    <td><div align="center"><?php echo $Result["DEVOLUCION_MM_DMM_ID"][$i];?></div></td>
  83.  
  84.  </tr>
  85. <?php
  86. }
  87. ?>
  88. </table>
  89.  
  90. <br>
  91. Total <?php $Num_Rows;?> Record : <?php $Num_Pages;?> Page :
  92. <?php
  93. if($Prev_Page)
  94. {
  95. echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page'><< Back</a> ";
  96. }
  97.  
  98. for($i=1; $i<=$Num_Pages; $i++){
  99. if($i != $Page)
  100. {
  101. echo "[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i'>$i</a> ]";
  102. }
  103. else
  104. {
  105. echo "<b> $i </b>";
  106. }
  107. }
  108. if($Page!=$Num_Pages)
  109. {
  110. echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page'>Next>></a> ";
  111. }
  112. //oci_close($objConnect);
  113. ?>
  114. </body>
  115. </html>
  116.  



De esta forma si me funciona pero como dije quisiera hacerlo en PDO

Código
  1.  
  2.     $dbhost = "localhost:1521/xe";
  3.   //  static public $mvc_bd_nombre   = "prueba_ccl";
  4.     $dbuser  = "HR";
  5.     $dbpass    = "1234";
  6.  
  7. $objConnect = oci_connect($dbuser,$dbpass,$dbhost);
  8. $strSQL = "SELECT PD_ID, PD_CANTIDAD, PRODUCTOS_PRO_ID, DEVOLUCION_MM_DMM_ID FROM PRODUCTO_DEVOLUCION ORDER BY PD_ID ASC";
  9. $objParse = oci_parse ($objConnect, $strSQL);
  10. oci_execute ($objParse,OCI_DEFAULT);
  11.  
  12. $Num_Rows = oci_fetch_all($objParse, $Result);
  13.  
  14.  
2  Programación / Desarrollo Web / Enviar formulario sin recargar en: 24 Noviembre 2014, 23:15 pm
Buenas parceros,

Estoy haciendo un pequeño codigo donde incrusto un input en una imagen y envio este formulario via jquery,ajax. El codigo esta bien y envia lo que necesito y todo pero quiero que me muestre un mensaje cuando le de al submit, algo asi como se envio correctametne.

Estoy probando pero no he podido solucionarlo, le agradeceria mucho su colaboracion

Código
  1. <html>
  2. <head>
  3. <script language="javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
  4. <script language="javascript">
  5. $(document).ready(function() {
  6.    $().ajaxStart(function() {
  7.        $('#loading').show();
  8.        $('#result').hide();
  9.    }).ajaxStop(function() {
  10.        $('#loading').hide();
  11.        $('#result').fadeIn('slow');
  12.    });
  13.    $('#form, #fat, #mc-embedded-subscribe-form').submit(function() {
  14.        $.ajax({
  15.            type: 'POST',
  16.            url: $(this).attr('action'),
  17.            data: $(this).serialize(),
  18.            success: function(data) {
  19.                $('#result').html(data);
  20.  
  21.            }
  22.        })
  23.  
  24.        return false;
  25.    });
  26. })  
  27. </script>
  28.  
  29.  
  30. <link href="//cdn-images.mailchimp.com/embedcode/classic-081711.css" rel="stylesheet" type="text/css">
  31.  
  32. <style type="text/css">
  33. .form-control {
  34.  width: 34%;
  35.  height: 30px;
  36.  padding: 10px 15px;
  37.  font-size: 15px;
  38.  line-height: 1.42857143;
  39.  color: #2c3e50;
  40.  background-color: #ffffff;
  41.  background-image: none;
  42.  border: 1px solid #dce4ec;
  43.  border-radius: 4px;
  44.  -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
  45.  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
  46.  -webkit-transition: border-color ease-in-out .15s, -webkit-box-shadow ease-in-out .15s;
  47.  -o-transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
  48.  transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
  49. }
  50. </style>
  51. </head>
  52. <body>
  53.  
  54.  
  55. <div id="mc_embed_signup">
  56. <form action="//ribot-barcelona.us5.list-manage.com/subscribe/post?u=d2c4a68aadfd8d6061877b0b2&amp;id=809315d24f" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" >
  57.  
  58. <table  align=center cellpadding=1 cellspacing=2 background="newsletter web_Ribot.jpg" height="415" width="754">
  59.  
  60. <tr>
  61. <td><br>&nbsp;</td>
  62. </tr>
  63.  
  64. <tr>
  65. <td><br>&nbsp;</td>
  66. </tr>
  67.  
  68. <tr>
  69. <td></td>
  70. <td align="right">
  71. <font color="white"><b>E-Mail</b></font> &nbsp;&nbsp;<input type="text" value="" name="EMAIL" id="mce-EMAIL" required class="form-control" >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br><br>
  72.  
  73.   <input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="button" >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  74.  
  75.  
  76.    <div id="result" ></div>
  77.  
  78.  
  79. </td>
  80. </tr>
  81.  
  82. </table>
  83. </form>
  84. </div>
  85.  
  86.  
  87.  
  88. </body>
  89. </html>
3  Programación / PHP / Como implementar función Ajax - Autocomplete en: 29 Septiembre 2014, 23:21 pm
Buenas parcero

Estoy realziando un proyecto en MCV + ORACLE y estoy en un dilema y no puedo hacer lo mas sencillo creo...

La idea es la siguiente, traigo varios valores de una consulta dinamica  id, producto, cantidad, etc.

En la columna productos deseo escribir el id del productos y este me debe mostrar al frente el nombre por medio de una funcion ajax.  funciona para la primera columna pero de hay para adelante si escribo en el siguiente ya no funciona pues como todos los input que se generan dinamicamente tienen el mismo name e id pues solo me va a mostrar en el primero.

Pues ya hize alguna pruebas secillas para cambiar el nombre e id del input en +1 pero quiero que cuando llege al ajax este haga lo mismo

Espero haber explicado bn

Aqui les dejo una captura






CONTROLADOR
Código
  1. public function listarProductosAjax()
  2.     {
  3.         $aux = $_POST['q'];
  4.        // $aux1 = $_GET['id'];
  5.  
  6.  
  7.         $m = new Model(Config::$mvc_bd_usuario,
  8.                     Config::$mvc_bd_clave, Config::$mvc_bd_hostname);
  9.  
  10.         $productoajax = $m->verProductoAjax($aux);
  11.  
  12.         $paramsVerAjax = $productoajax;
  13.  
  14.  
  15.  
  16.        return $paramsVerAjax;
  17.     }


MODELO
Código
  1.     public function verProductoAjax($id)
  2.        {
  3.         $id = htmlspecialchars($id);
  4.         $id1=1;
  5.  
  6.         $sql="select PRO_NOMBRE from PRODUCTOS where PRO_ID LIKE '".$id."%'";
  7.  
  8.  
  9.         $result = oci_parse($this->conexion,$sql);
  10.         oci_execute($result, OCI_DEFAULT);
  11.         //$devolucion = array();
  12.  
  13.         $row = oci_fetch_array($result);
  14.        echo $row['PRO_NOMBRE'];
  15.        // $row = $result;
  16.        // return $row;
  17.        }

VISTAS
Código
  1. <div class="table-responsive">
  2. <table align="center" class="table table-condensed table-hover">
  3.     <tr>
  4.         <th>#</th>
  5.         <th>Producto</th>
  6.         <th>...</th>
  7.         <th>Cantidad</th>
  8.         <th>Reserva</th>        
  9.         <th>Producto</th>
  10.         <th>Cantidad</th>
  11.  
  12.         <th>Tipo Reserva</th>
  13.  
  14.  
  15.     </tr>
  16.  
  17. <?php
  18.  
  19.  
  20. ?>
  21.  <?php foreach ($paramsPD['productoD'] as $paramsPD1) :?>
  22. <?php
  23.  
  24.  
  25. $nameb="bus";
  26. $sum++;
  27. //$sumando=$sum+1;
  28. $bus=$nameb.$sum;
  29. echo $bus;
  30. ?>
  31.  
  32.     <tr>
  33.         <td><?php echo $paramsPD1['PD_ID'] ?></td>
  34.         <td>        
  35.  
  36.  
  37. [B]          Buscar <input type="text" id="<?php echo $bus ?>"
  38. name="<?php echo $bus ?>" onkeyup="loadXMLDoc()" required /></td>
  39.  
  40. <td><div id="myDiv"> </div></td>
  41. [/B]
  42.  
  43.         <td><input type="number" name="cantidad" min="1" required placeholder="Cantidad de Productos" class="form-control" id="" size="" value="<?php echo $paramsPD1['PD_CANTIDAD']?>"/></td>
  44.  
  45.  
  46.  
  47. .....
  48.  
  49.  
  50.     </tr>
  51.     <?php endforeach; ?>
  52.  
  53.  


AJAX
Código
  1. function loadXMLDoc()
  2. {
  3. var xmlhttp;
  4.  
  5. var n=document.getElementById('bus1').value;
  6.  
  7. if(n==''){
  8. document.getElementById("myDiv").innerHTML="";
  9. return;
  10. }
  11.  
  12. if (window.XMLHttpRequest)
  13.  {// code for IE7+, Firefox, Chrome, Opera, Safari
  14.  xmlhttp=new XMLHttpRequest();
  15.  }
  16. else
  17.  {// code for IE6, IE5
  18.  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  19.  }
  20. xmlhttp.onreadystatechange=function()
  21.  {
  22.  if (xmlhttp.readyState==4 && xmlhttp.status==200)
  23.    {
  24.    document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
  25.    }else{ document.getElementById("myDiv").innerHTML='<img src="load.gif" width="50" height="50" />'; }
  26.  }
  27. xmlhttp.open("POST","index.php?ctl=buscarajax",true);
  28. xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
  29. xmlhttp.send("q="+n);
  30. }
  31.  

[Mod]: Temas de PHP van al subforo de PHP.
Páginas: [1]
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines