Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $conexion = mysql_connect("localhost", "root", "");
- mysql_select_db("lproduccion", $conexion);
- echo "Productos en Taller Torpedo:"."<br>";
- $que1 = "SELECT nom_pro, nom_taller FROM productos LEFT JOIN lotes ON productos.id_pro=lotes.id_pro
- LEFT JOIN talleres ON lotes.id_tall=talleres.id_tall WHERE nom_taller='torpedo'";
- $res1 = mysql_query($que1, $conexion);
- $tot1 = mysql_num_rows($res1);
- if ($tot1> 0) {
- while ($row1 = mysql_fetch_assoc($res1)) {
- echo "Nombre: ".$row1['nom_pro']."<br>";
- }
- }
- echo "Productos en Taller Fireball:"."<br>";
- $que2 = "SELECT nom_pro, nom_taller FROM productos LEFT JOIN lotes ON productos.id_pro=lotes.id_pro
- LEFT JOIN talleres ON lotes.id_tall=talleres.id_tall WHERE nom_taller='fireball'";
- $res2 = mysql_query($que2, $conexion);
- $tot2 = mysql_num_rows($res2);
- if ($tot2> 0) {
- while ($row2 = mysql_fetch_assoc($res2)) {
- echo "Nombre: ".$row2['nom_pro']."<br>";
- }
- }
- echo "-------------------------------------------------------------------"."<br>";
- $que3 = "SELECT nom_taller, id_lot, fec_lot, can_pro FROM lotes LEFT JOIN talleres ON lotes.id_tall=talleres.id_tall";
- $res3 = mysql_query($que3, $conexion);
- $tot3 = mysql_num_rows($res3);
- if ($tot3> 0) {
- while ($row3 = mysql_fetch_assoc($res3)) {
- echo "Nombre del Taller: ".$row3['nom_taller']."<br>";
- echo "Id del Lote: ".$row3['id_lot']."<br>";
- }
- }
- echo "-------------------------------------------------------------------"."<br>";
- $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";
- $res4 = mysql_query($que4, $conexion);
- $tot4 = mysql_num_rows($res4);
- if ($tot4> 0) {
- while ($row4 = mysql_fetch_assoc($res4)) {
- echo "Nombre del Taller: ".$row4['nom_taller']."<br>";
- echo "Ciudad: ".$row4['nom_ciu']."<br>";
- echo "Zona: ".$row4['nom_zon']."<br>";
- }
- }
- echo "-------------------------------------------------------------------"."<br>";
- $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";
- $res5 = mysql_query($que5, $conexion);
- $tot5 = mysql_num_rows($res5);
- if ($tot5> 0) {
- while ($row5 = mysql_fetch_assoc($res5)) {
- echo "Nombre del Taller: ".$row5['nom_taller']."<br>";
- echo "Auto: ".$row5['id_aut']."<br>";
- }
- }
- echo "-------------------------------------------------------------------"."<br>";
- mysql_select_db("lventas", $conexion);
- echo "Ventas por distribuidor en el 2011"."<br>";
- $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'";
- $res6 = mysql_query($que6, $conexion);
- $tot6 = mysql_num_rows($res6);
- if ($tot6> 0) {
- while ($row6 = mysql_fetch_assoc($res6)) {
- echo "Venta: ".$row6['id_vent']."<br>";
- echo "Distribuidor: ".$row6['nom_dis']."<br>";
- }
- }
- echo "-------------------------------------------------------------------"."<br>";
- echo "Ventas por vendedor en el 2011"."<br>";
- $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";
- $res7 = mysql_query($que7, $conexion);
- $tot7 = mysql_num_rows($res7);
- if ($tot7> 0) {
- while ($row7 = mysql_fetch_assoc($res7)) {
- echo "Vendedor: ".$row7['nom_ven']."<br>";
- echo "Id Venta: ".$row7['id_vent']."<br>";
- }
- }
- echo "-------------------------------------------------------------------"."<br>";
- echo "Compradores masculinos por auto"."<br>";
- $que8 = "SELECT ventas.id_aut, nom_com, sex_com FROM compradores LEFT JOIN ventas ON compradores.id_com=ventas.id_com
- LEFT JOIN autos ON ventas.id_aut=autos.id_aut WHERE compradores.sex_com='masculino' ORDER BY id_aut";
- $res8 = mysql_query($que8, $conexion);
- $tot8 = mysql_num_rows($res8);
- if ($tot8> 0) {
- while ($row8 = mysql_fetch_assoc($res8)) {
- echo "Id Auto: ".$row8['id_aut']."<br>";
- echo "Comprador: ".$row8['nom_com']."<br>";
- }
- }
- echo "-------------------------------------------------------------------"."<br>";
- echo "Compradores femeninos por auto"."<br>";
- $que9 = "SELECT ventas.id_aut, nom_com, sex_com FROM compradores LEFT JOIN ventas ON compradores.id_com=ventas.id_com
- LEFT JOIN autos ON ventas.id_aut=autos.id_aut WHERE compradores.sex_com='femenino' ORDER BY id_aut";
- $res9 = mysql_query($que9, $conexion);
- $tot9 = mysql_num_rows($res9);
- if ($tot9> 0) {
- while ($row9 = mysql_fetch_assoc($res9)) {
- echo "Id Auto: ".$row9['id_aut']."<br>";
- echo "Comprador: ".$row9['nom_com']."<br>";
- }
- }
- $conexion2 = mysql_connect("localhost", "root", "", true);
- $createquery = mysql_query("CREATE DATABASE dwlaser", $conexion2);
- mysql_select_db("dwlaser", $conexion2) or die("Cannot select database");
- $create_prod_tall = mysql_query("CREATE TABLE dwlaser.prod_tall (productos VARCHAR (250) NOT NULL, taller VARCHAR (250) NOT NULL)", $conexion2);
- $create_tall_lot = mysql_query("CREATE TABLE dwlaser.tall_lot (talleres VARCHAR (250) NOT NULL, lotes INT (250) NOT NULL)", $conexion2);
- $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);
- $create_aut_tall = mysql_query("CREATE TABLE dwlaser.aut_tall (autos INT (250) NOT NULL, taller VARCHAR (250) NOT NULL)", $conexion2);
- mysql_query("INSERT INTO dwlaser.prod_tall (productos, taller) VALUES ('temp1','temp2')",$conexion2);
- while($temp = mysql_fetch_array($res1))
- {
- echo $temp[0];
- $valores_productos_taller = mysql_query("INSERT INTO dwlaser.prod_tall (productos, taller) VALUES ('$temp[0]', '$temp[1]')", $conexion2);
- echo " | ";
- echo $temp[1];
- echo "<br>";
- echo "<br>";
- }
- ?>
Add Comment
Please, Sign In to add comment