Guest User

Untitled

a guest
Oct 21st, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.91 KB | None | 0 0
  1. <?php
  2. $conexion = mysql_connect("localhost", "root", "");
  3. mysql_select_db("lproduccion", $conexion);
  4.  
  5. echo "Productos en Taller Torpedo:"."<br>";
  6. $que1 = "SELECT nom_pro, nom_taller FROM productos LEFT JOIN lotes ON productos.id_pro=lotes.id_pro
  7. LEFT JOIN talleres ON lotes.id_tall=talleres.id_tall WHERE nom_taller='torpedo'";
  8. $res1 = mysql_query($que1, $conexion);
  9. $tot1 = mysql_num_rows($res1);
  10. if ($tot1> 0) {
  11. while ($row1 = mysql_fetch_assoc($res1)) {
  12. echo "Nombre: ".$row1['nom_pro']."<br>";
  13. }
  14. }
  15. echo "Productos en Taller Fireball:"."<br>";
  16. $que2 = "SELECT nom_pro, nom_taller FROM productos LEFT JOIN lotes ON productos.id_pro=lotes.id_pro
  17. LEFT JOIN talleres ON lotes.id_tall=talleres.id_tall WHERE nom_taller='fireball'";
  18. $res2 = mysql_query($que2, $conexion);
  19. $tot2 = mysql_num_rows($res2);
  20. if ($tot2> 0) {
  21. while ($row2 = mysql_fetch_assoc($res2)) {
  22. echo "Nombre: ".$row2['nom_pro']."<br>";
  23. }
  24. }
  25. echo "-------------------------------------------------------------------"."<br>";
  26. $que3 = "SELECT nom_taller, id_lot, fec_lot, can_pro FROM lotes LEFT JOIN talleres ON lotes.id_tall=talleres.id_tall";
  27. $res3 = mysql_query($que3, $conexion);
  28. $tot3 = mysql_num_rows($res3);
  29. if ($tot3> 0) {
  30. while ($row3 = mysql_fetch_assoc($res3)) {
  31. echo "Nombre del Taller: ".$row3['nom_taller']."<br>";
  32. echo "Id del Lote: ".$row3['id_lot']."<br>";
  33. }
  34. }
  35. echo "-------------------------------------------------------------------"."<br>";
  36. $que4 = "SELECT nom_taller, nom_ciu, nom_zon FROM talleres LEFT JOIN ciudades ON talleres.id_ciu=ciudades.id_ciu LEFT JOIN zonas ON ciudades.id_zon=zonas.id_zon";
  37. $res4 = mysql_query($que4, $conexion);
  38. $tot4 = mysql_num_rows($res4);
  39. if ($tot4> 0) {
  40. while ($row4 = mysql_fetch_assoc($res4)) {
  41. echo "Nombre del Taller: ".$row4['nom_taller']."<br>";
  42. echo "Ciudad: ".$row4['nom_ciu']."<br>";
  43. echo "Zona: ".$row4['nom_zon']."<br>";
  44. }
  45. }
  46. echo "-------------------------------------------------------------------"."<br>";
  47. $que5 = "SELECT id_aut, nom_taller FROM autos LEFT JOIN lotes ON autos.id_lot=lotes.id_lot LEFT JOIN talleres ON lotes.id_tall=talleres.id_tall";
  48. $res5 = mysql_query($que5, $conexion);
  49. $tot5 = mysql_num_rows($res5);
  50. if ($tot5> 0) {
  51. while ($row5 = mysql_fetch_assoc($res5)) {
  52. echo "Nombre del Taller: ".$row5['nom_taller']."<br>";
  53. echo "Auto: ".$row5['id_aut']."<br>";
  54. }
  55. }
  56. echo "-------------------------------------------------------------------"."<br>";
  57. mysql_select_db("lventas", $conexion);
  58. echo "Ventas por distribuidor en el 2011"."<br>";
  59. $que6 = "SELECT id_vent, nom_dis FROM ventas LEFT JOIN vendedores ON ventas.id_ven=vendedores.id_ven LEFT JOIN distribuidores ON vendedores.id_dis=distribuidores.id_dis WHERE date_format(ventas.fec_vent,'%Y')='2011'";
  60. $res6 = mysql_query($que6, $conexion);
  61. $tot6 = mysql_num_rows($res6);
  62. if ($tot6> 0) {
  63. while ($row6 = mysql_fetch_assoc($res6)) {
  64. echo "Venta: ".$row6['id_vent']."<br>";
  65. echo "Distribuidor: ".$row6['nom_dis']."<br>";
  66. }
  67. }
  68. echo "-------------------------------------------------------------------"."<br>";
  69. echo "Ventas por vendedor en el 2011"."<br>";
  70. $que7 = "SELECT nom_ven, id_vent FROM ventas LEFT JOIN vendedores ON ventas.id_ven=vendedores.id_ven WHERE date_format(ventas.fec_vent,'%Y')='2011' ORDER BY nom_ven";
  71. $res7 = mysql_query($que7, $conexion);
  72. $tot7 = mysql_num_rows($res7);
  73. if ($tot7> 0) {
  74. while ($row7 = mysql_fetch_assoc($res7)) {
  75. echo "Vendedor: ".$row7['nom_ven']."<br>";
  76. echo "Id Venta: ".$row7['id_vent']."<br>";
  77. }
  78. }
  79. echo "-------------------------------------------------------------------"."<br>";
  80. echo "Compradores masculinos por auto"."<br>";
  81. $que8 = "SELECT ventas.id_aut, nom_com, sex_com FROM compradores LEFT JOIN ventas ON compradores.id_com=ventas.id_com
  82. LEFT JOIN autos ON ventas.id_aut=autos.id_aut WHERE compradores.sex_com='masculino' ORDER BY id_aut";
  83. $res8 = mysql_query($que8, $conexion);
  84. $tot8 = mysql_num_rows($res8);
  85. if ($tot8> 0) {
  86. while ($row8 = mysql_fetch_assoc($res8)) {
  87. echo "Id Auto: ".$row8['id_aut']."<br>";
  88. echo "Comprador: ".$row8['nom_com']."<br>";
  89. }
  90. }
  91. echo "-------------------------------------------------------------------"."<br>";
  92. echo "Compradores femeninos por auto"."<br>";
  93. $que9 = "SELECT ventas.id_aut, nom_com, sex_com FROM compradores LEFT JOIN ventas ON compradores.id_com=ventas.id_com
  94. LEFT JOIN autos ON ventas.id_aut=autos.id_aut WHERE compradores.sex_com='femenino' ORDER BY id_aut";
  95. $res9 = mysql_query($que9, $conexion);
  96. $tot9 = mysql_num_rows($res9);
  97. if ($tot9> 0) {
  98. while ($row9 = mysql_fetch_assoc($res9)) {
  99. echo "Id Auto: ".$row9['id_aut']."<br>";
  100. echo "Comprador: ".$row9['nom_com']."<br>";
  101. }
  102. }
  103.  
  104. $conexion2 = mysql_connect("localhost", "root", "", true);
  105. $createquery = mysql_query("CREATE DATABASE dwlaser", $conexion2);
  106. mysql_select_db("dwlaser", $conexion2) or die("Cannot select database");
  107.  
  108. $create_prod_tall = mysql_query("CREATE TABLE dwlaser.prod_tall (productos VARCHAR (250) NOT NULL, taller VARCHAR (250) NOT NULL)", $conexion2);
  109. $create_tall_lot = mysql_query("CREATE TABLE dwlaser.tall_lot (talleres VARCHAR (250) NOT NULL, lotes INT (250) NOT NULL)", $conexion2);
  110. $create_tall_ciud_zon = mysql_query("CREATE TABLE dwlaser.tall_ciud_zon (taller VARCHAR (250) NOT NULL, ciudad VARCHAR (250) NOT NULL, zona VARCHAR (250) NOT NULL)", $conexion2);
  111. $create_aut_tall = mysql_query("CREATE TABLE dwlaser.aut_tall (autos INT (250) NOT NULL, taller VARCHAR (250) NOT NULL)", $conexion2);
  112.  
  113.  
  114. mysql_query("INSERT INTO dwlaser.prod_tall (productos, taller) VALUES ('temp1','temp2')",$conexion2);
  115.  
  116. while($temp = mysql_fetch_array($res1))
  117. {
  118. echo $temp[0];
  119. $valores_productos_taller = mysql_query("INSERT INTO dwlaser.prod_tall (productos, taller) VALUES ('$temp[0]', '$temp[1]')", $conexion2);
  120. echo " | ";
  121. echo $temp[1];
  122. echo "<br>";
  123. echo "<br>";
  124. }
  125.  
  126.  
  127. ?>
Add Comment
Please, Sign In to add comment