Ver Mensaje Individual
  #2 (permalink)  
Antiguo 14/12/2014, 12:00
gralf
 
Fecha de Ingreso: noviembre-2014
Mensajes: 76
Antigüedad: 10 años
Puntos: 0
Respuesta: mostrar resultado de un modo un tanto especial

intento con dreamweaver crear regiones repetidas, pero horizontalmente, que creo, es lo que necesito, no me deja hacerlo, o no se como.

de hecho he intentado para la primera fila, en l que solo deben salir dos resultados hacer la consulta con un limit 1,2, y da error

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIMIT 0, 2' at line 1

el código es este

Código PHP:
Ver original
  1. <?php require_once('Connections/conexxion.php'); ?>
  2. <?php
  3. if (!function_exists("GetSQLValueString")) {
  4. function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
  5. {
  6.   if (PHP_VERSION < 6) {
  7.     $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  8.   }
  9.  
  10.   $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  11.  
  12.   switch ($theType) {
  13.     case "text":
  14.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  15.       break;    
  16.     case "long":
  17.     case "int":
  18.       $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  19.       break;
  20.     case "double":
  21.       $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
  22.       break;
  23.     case "date":
  24.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  25.       break;
  26.     case "defined":
  27.       $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  28.       break;
  29.   }
  30.   return $theValue;
  31. }
  32. }
  33.  
  34. mysql_select_db($database_conexxion, $conexxion);
  35. $query_Recordset2 = "select venta,compra,taller,regula_mas,regula_menos,movimiento.id_item,sum(compra+regula_mas-venta-taller-regula_menos)  as stock, cilindro, esfera from movimiento  join item on item.id_item=movimiento.id_item join rx on rx.id_rx=item.id_rx join cilindro  on cilindro.id_cil=rx.id_cil  join esfera  on esfera.id_esf=rx.id_esf  group by movimiento.id_item order by esfera desc, cilindro desc;";
  36. $Recordset2 = mysql_query($query_Recordset2, $conexxion) or die(mysql_error());
  37. $row_Recordset2 = mysql_fetch_assoc($Recordset2);
  38. $totalRows_Recordset2 = mysql_num_rows($Recordset2);
  39.  
  40. mysql_select_db($database_conexxion, $conexxion);
  41. $query_solostock149nc = "SELECT movimiento.id_item,sum(compra+regula_mas-venta-taller-regula_menos)  as stock, cilindro, esfera FROM movimiento  join item on item.id_item=movimiento.id_item join rx on rx.id_rx=item.id_rx join cilindro  on cilindro.id_cil=rx.id_cil  join esfera  on esfera.id_esf=rx.id_esf GROUP BY movimiento.id_item ORDER BY esfera desc, cilindro desc";
  42. $solostock149nc = mysql_query($query_solostock149nc, $conexxion) or die(mysql_error());
  43. $row_solostock149nc = mysql_fetch_assoc($solostock149nc);
  44. $totalRows_solostock149nc = mysql_num_rows($solostock149nc);
  45.  
  46. mysql_select_db($database_conexxion, $conexxion);
  47. $query_stock1 = "select venta,compra,taller,regula_mas,regula_menos,movimiento.id_item,sum(compra+regula_mas-venta-taller-regula_menos)  as stock, cilindro, esfera from movimiento  join item on item.id_item=movimiento.id_item join rx on rx.id_rx=item.id_rx join cilindro  on cilindro.id_cil=rx.id_cil  join esfera  on esfera.id_esf=rx.id_esf  group by movimiento.id_item order by esfera desc, cilindro desc limit 1";
  48. $stock1 = mysql_query($query_stock1, $conexxion) or die(mysql_error());
  49. $row_stock1 = mysql_fetch_assoc($stock1);
  50. $totalRows_stock1 = mysql_num_rows($stock1);
  51.  
  52. $maxRows_stock2 = 2;
  53. $pageNum_stock2 = 0;
  54. if (isset($_GET['pageNum_stock2'])) {
  55.   $pageNum_stock2 = $_GET['pageNum_stock2'];
  56. }
  57. $startRow_stock2 = $pageNum_stock2 * $maxRows_stock2;
  58.  
  59. mysql_select_db($database_conexxion, $conexxion);
  60. $query_stock2 = "SELECT venta,compra,taller,regula_mas,regula_menos,movimiento.id_item,sum(compra+regula_mas-venta-taller-regula_menos)  as stock, cilindro, esfera FROM movimiento  join item on item.id_item=movimiento.id_item join rx on rx.id_rx=item.id_rx join cilindro  on cilindro.id_cil=rx.id_cil  join esfera  on esfera.id_esf=rx.id_esf GROUP BY movimiento.id_item ORDER BY esfera desc, cilindro desc limit 1,1";
  61. $query_limit_stock2 = sprintf("%s LIMIT %d, %d", $query_stock2, $startRow_stock2, $maxRows_stock2);
  62. $stock2 = mysql_query($query_limit_stock2, $conexxion) or die(mysql_error());
  63. $row_stock2 = mysql_fetch_assoc($stock2);
  64.  
  65. if (isset($_GET['totalRows_stock2'])) {
  66.   $totalRows_stock2 = $_GET['totalRows_stock2'];
  67. } else {
  68.   $all_stock2 = mysql_query($query_stock2);
  69.   $totalRows_stock2 = mysql_num_rows($all_stock2);
  70. }
  71. $totalPages_stock2 = ceil($totalRows_stock2/$maxRows_stock2)-1;
  72.  
  73. mysql_select_db($database_conexxion, $conexxion);
  74. $query_stock3 = "SELECT venta,compra,taller,regula_mas,regula_menos,movimiento.id_item,sum(compra+regula_mas-venta-taller-regula_menos)  as stock, cilindro, esfera FROM movimiento  join item on item.id_item=movimiento.id_item join rx on rx.id_rx=item.id_rx join cilindro  on cilindro.id_cil=rx.id_cil  join esfera  on esfera.id_esf=rx.id_esf GROUP BY movimiento.id_item ORDER BY esfera desc, cilindro desc limit 2,2";
  75. $stock3 = mysql_query($query_stock3, $conexxion) or die(mysql_error());
  76. $row_stock3 = mysql_fetch_assoc($stock3);
  77. $totalRows_stock3 = mysql_num_rows($stock3);
  78. ?>
  79. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  80. <html xmlns="http://www.w3.org/1999/xhtml">
  81. <head>
  82. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  83. <title>1.49NC</title>
  84. </head>
  85.  
  86. <body>
  87.  
  88. <p>pruebas</p>
  89. <p>&nbsp;</p>
  90. <p>&nbsp;</p>
  91. <table width="80%" border="1">
  92.   <tr>
  93.     <td>&nbsp;</td>
  94.     <td>0.00</td>
  95.     <td>-0.25</td>
  96.     <td>-0.50</td>
  97.     <td>-0.75</td>
  98.     <td>-1.00</td>
  99.     <td>-1.25</td>
  100.     <td>-1.50</td>
  101.     <td>-1.75</td>
  102.     <td>-2.00</td>
  103.   </tr>
  104.   <tr>
  105.     <td>4.00</td>
  106.     <td><?php echo $row_stock1['stock']; ?></td>
  107.     <td bgcolor="#333333">&nbsp;</td>
  108.     <td bgcolor="#333333">&nbsp;</td>
  109.     <td bgcolor="#333333">&nbsp;</td>
  110.     <td bgcolor="#333333">&nbsp;</td>
  111.     <td bgcolor="#333333">&nbsp;</td>
  112.     <td bgcolor="#333333">&nbsp;</td>
  113.     <td bgcolor="#333333">&nbsp;</td>
  114.     <td bgcolor="#333333">&nbsp;</td>
  115.   </tr>
  116.   <tr>
  117.     <td>3.75</td>
  118.    
  119.     <td><?php do { ?>
  120.           <?php echo $row_stock2['stock']; ?>
  121.           <?php } while ($row_stock2 = mysql_fetch_assoc($stock2)); ?></td>
  122.       <td>&nbsp;</td>
  123.     <td bgcolor="#333333">&nbsp;</td>
  124.     <td bgcolor="#333333">&nbsp;</td>
  125.     <td bgcolor="#333333">&nbsp;</td>
  126.     <td bgcolor="#333333">&nbsp;</td>
  127.     <td bgcolor="#333333">&nbsp;</td>
  128.     <td bgcolor="#333333">&nbsp;</td>
  129.     <td bgcolor="#333333">&nbsp;</td>
  130.   </tr>
  131.   <tr>
  132.     <td>3.50</td>
  133.     <td>&nbsp;</td>
  134.     <td>&nbsp;</td>
  135.     <td>&nbsp;</td>
  136.     <td bgcolor="#333333">&nbsp;</td>
  137.     <td bgcolor="#333333">&nbsp;</td>
  138.     <td bgcolor="#333333">&nbsp;</td>
  139.     <td bgcolor="#333333">&nbsp;</td>
  140.     <td bgcolor="#333333">&nbsp;</td>
  141.     <td bgcolor="#333333">&nbsp;</td>
  142.   </tr>
  143.   <tr>
  144.     <td>3.25</td>
  145.     <td>&nbsp;</td>
  146.     <td>&nbsp;</td>
  147.     <td>&nbsp;</td>
  148.     <td>&nbsp;</td>
  149.     <td bgcolor="#333333">&nbsp;</td>
  150.     <td bgcolor="#333333">&nbsp;</td>
  151.     <td bgcolor="#333333">&nbsp;</td>
  152.     <td bgcolor="#333333">&nbsp;</td>
  153.     <td bgcolor="#333333">&nbsp;</td>
  154.   </tr>
  155.   <tr>
  156.     <td>3.00</td>
  157.     <td>&nbsp;</td>
  158.     <td>&nbsp;</td>
  159.     <td>&nbsp;</td>
  160.     <td>&nbsp;</td>
  161.     <td>&nbsp;</td>
  162.     <td bgcolor="#333333">&nbsp;</td>
  163.     <td bgcolor="#333333">&nbsp;</td>
  164.     <td bgcolor="#333333">&nbsp;</td>
  165.     <td bgcolor="#333333">&nbsp;</td>
  166.   </tr>
  167.   <tr>
  168.     <td>2.75</td>
  169.     <td>&nbsp;</td>
  170.     <td>&nbsp;</td>
  171.     <td>&nbsp;</td>
  172.     <td>&nbsp;</td>
  173.     <td>&nbsp;</td>
  174.     <td>&nbsp;</td>
  175.     <td bgcolor="#333333">&nbsp;</td>
  176.     <td bgcolor="#333333">&nbsp;</td>
  177.     <td bgcolor="#333333">&nbsp;</td>
  178.   </tr>
  179.   <tr>
  180.     <td>2.50</td>
  181.     <td>&nbsp;</td>
  182.     <td>&nbsp;</td>
  183.     <td>&nbsp;</td>
  184.     <td>&nbsp;</td>
  185.     <td>&nbsp;</td>
  186.     <td>&nbsp;</td>
  187.     <td>&nbsp;</td>
  188.     <td bgcolor="#333333">&nbsp;</td>
  189.     <td bgcolor="#333333">&nbsp;</td>
  190.   </tr>
  191.   <tr>
  192.     <td>2.25</td>
  193.     <td>&nbsp;</td>
  194.     <td>&nbsp;</td>
  195.     <td>&nbsp;</td>
  196.     <td>&nbsp;</td>
  197.     <td>&nbsp;</td>
  198.     <td>&nbsp;</td>
  199.     <td>&nbsp;</td>
  200.     <td>&nbsp;</td>
  201.     <td bgcolor="#333333">&nbsp;</td>
  202.   </tr>
  203.   <tr>
  204.     <td>2.00</td>
  205.     <td></td>
  206.     <td>&nbsp;</td>
  207.     <td>&nbsp;</td>
  208.     <td>&nbsp;</td>
  209.     <td>&nbsp;</td>
  210.     <td>&nbsp;</td>
  211.     <td>&nbsp;</td>
  212.     <td>&nbsp;</td>
  213.     <td>&nbsp;</td>
  214.   </tr>
  215.   <tr>
  216.     <td>1.75</td>
  217.     <td>&nbsp;</td>
  218.     <td>&nbsp;</td>
  219.     <td>&nbsp;</td>
  220.     <td>&nbsp;</td>
  221.     <td>&nbsp;</td>
  222.     <td>&nbsp;</td>
  223.     <td>&nbsp;</td>
  224.     <td>&nbsp;</td>
  225.     <td>&nbsp;</td>
  226.   </tr>
  227.   <tr>
  228.     <td>1.50</td>
  229.     <td>&nbsp;</td>
  230.     <td>&nbsp;</td>
  231.     <td>&nbsp;</td>
  232.     <td>&nbsp;</td>
  233.     <td>&nbsp;</td>
  234.     <td>&nbsp;</td>
  235.     <td>&nbsp;</td>
  236.     <td>&nbsp;</td>
  237.     <td>&nbsp;</td>
  238.   </tr>
  239. </table>
  240. </body>
  241. </html>
  242. <?php
  243. mysql_free_result($Recordset2);
  244.  
  245. mysql_free_result($solostock149nc);
  246.  
  247.  
  248.  
  249. ?>