Foros del Web » Programando para Internet » PHP »

No me muestra resultados Paginador PHP,MYSQL

Estas en el tema de No me muestra resultados Paginador PHP,MYSQL en el foro de PHP en Foros del Web. Buenas, Estoy implementando este sencillo paginador, me funciono bn pero cuando trate de hacerlo con PDO no me muestra los valores pero si muestra cuantos ...
  #1 (permalink)  
Antiguo 29/10/2014, 11:09
 
Fecha de Ingreso: septiembre-2010
Mensajes: 12
Antigüedad: 13 años, 7 meses
Puntos: 0
Pregunta No me muestra resultados Paginador PHP,MYSQL

Buenas,

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


Código PHP:
Ver original
  1. <html>
  2. <head>
  3. <title>ShotDev.Com Tutorial</title>
  4. </head>
  5. <body>
  6. <?php
  7. $db_username = "HR";
  8. $db_password = "1234";
  9. $db = "oci:dbname=localhost:1521/xe";
  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>



De esta forma si me funciona pero como dije quisiera hacerlo en PDO
Código PHP:
Ver original
  1. //error_reporting(0);
  2. /*
  3.      $dbhost = "localhost:1521/xe";
  4.    //  static public $mvc_bd_nombre   = "prueba_ccl";
  5.      $dbuser  = "HR";
  6.      $dbpass    = "1234";
  7.    
  8. $objConnect = oci_connect($dbuser,$dbpass,$dbhost);
  9. $strSQL = "SELECT PD_ID, PD_CANTIDAD, PRODUCTOS_PRO_ID, DEVOLUCION_MM_DMM_ID FROM PRODUCTO_DEVOLUCION ORDER BY PD_ID ASC";
  10. $objParse = oci_parse ($objConnect, $strSQL);
  11. oci_execute ($objParse,OCI_DEFAULT);
  12.  
  13. $Num_Rows = oci_fetch_all($objParse, $Result);
  14.  
  15. */
  #2 (permalink)  
Antiguo 04/11/2014, 08:16
 
Fecha de Ingreso: septiembre-2010
Mensajes: 12
Antigüedad: 13 años, 7 meses
Puntos: 0
Respuesta: No me muestra resultados Paginador PHP,MYSQL

sigo sin poder implementarlo, bueno he estado ocupado con otras cosas y he dejado esto pa lo ultimo, si alguien me puede ayudar se lo agradeceria mucho

Etiquetas: html, muestra, paginador, php-mysql, resultados, select, sql
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 19:10.