Advertisement
Guest User

Untitled

a guest
Dec 6th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.20 KB | None | 0 0
  1. <?php
  2. $sql= mysql_query("SELECT * FROM repuesto");
  3. while($res= mysql_fetch_array($sql)){
  4. echo '<form action="descripcion.php" method="POST">';
  5. echo '<div class="col">';
  6. echo '<figure class="img-border"><a href="descripcion.php"><img src="../Administrador/pages/RepuestoCRUD/'.$res["imagen_repuesto"].'"width="230" heigth="220"></a></figure>';
  7. echo'<h6>'.$res["nombre_repuesto"].'</h6>';
  8. echo'<h6>$'.$res["precio_repuesto"].'</h6>';
  9. echo'<p class="p2">'.$res["descripcion_repuesto"].'</p>';
  10. echo '<input type="submit" value="Aceptar">';
  11. echo'<a class="button" href="descripcion.php">Leer Mas</a>';
  12. echo '</div>';
  13. echo '</form>';
  14. }
  15.  
  16. ?>
  17.  
  18. /******** CONECTAR CON BASE DE DATOS **************** */
  19.  
  20. $con = mysql_connect("localhost","root","");
  21. if (!$con){die('ERROR DE CONEXION CON MYSQL: ' . mysql_error());}
  22. /* ********************************************** */
  23.  
  24. /********* CONECTA CON LA BASE DE DATOS **************** */
  25. $database = mysql_select_db("sicoa",$con);
  26. if (!$database){die('ERROR CONEXION CON BD: '.mysql_error());}
  27. /* ********************************************** */
  28.  
  29. //ejecutamos la consulta
  30. $sql = "SELECT nombre_repuesto, descripcion_repuesto, precio_repuesto FROM repuesto WHERE idrepuesto='"
  31. .$_POST['idrepuesto']."'";
  32. $result = mysql_query ($sql);
  33. // verificamos que no haya error
  34. if (! $result){
  35. echo "La consulta SQL contiene errores.".mysql_error();
  36. exit();
  37. }else {
  38. echo "<table border='1'><tr><td>Nombre</td><td>Precio</td><td>Existencia</td>
  39. </tr><tr>";
  40. //obtenemos los datos resultado de la consulta
  41. while ($row = mysql_fetch_row($result)){
  42. echo "<td>".$row[0]."</td><td>".$row[1]."</td>
  43. <td>".$row[2]."</td>";
  44. }
  45. echo "</tr></table>";
  46. }
  47. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement