Conexión.
………………………………………………………………………………………………………………………………………………………
<?php
$conexion = mysql_connect("localhost", "root", "";
mysql_select_db("escuela", $conexion);
$host="localhost";
$user="root";
$pw="";
$db="escuela"
?>
Consultar consultas.php
<html>
<head><title>Ejemplo de php</title></head>
<body>
<h2>Ejemplo de base de datos con php</h2>
<table border="1">
<tr>
<td>Idprofe</td><td>Nombre</td><td>Apellido</td><td>Direccion</td><td>Tipo semestre</td>
</tr>
<?php
include("Conexion.php";
$consulta=mysql_query("select * from profe;", $conexion);
while($reg=mysql_fetch_array($consulta))
{
echo "<tr><td>".$reg['idProfe']."</td><td>".$reg['Nombre']."</td><td>".$reg['Apellido']."</td><td>".$reg['Direccion']."</td><td>".$reg['Tipo_Semestre']."</td></tr>";
}
mysql_close($conexion);
?>
</table>
</body>
</html>
……………………………………………………………………………………………………………………………………………………..
Insertar
……………………………………………………………………………………………………………………………………………………..
<!DOCTYPE HTML>
<head>
<title>Untitled 1</title>
</head>
<form name="Formulario" method="Post" action="insert.php">
<body>
<table>
<tr><td>Inserta tu Id</td><td><input type="text" name="Id"/></td></tr>
<tr><td>Inserta Nombre</td><td><input type="text" name="Nombre" /></td></tr>
<tr><td>Insertar apellido</td><td><input type="text" name="Apellido" /></td></tr>
<tr><td>Inserte direccion</td><td><input type="text" name="Direccion" /></td></tr>
<tr><td>Inserte semestre</td><td><input type="text" name="Tipo" /></td></tr>
<tr><td></td><td><input type="submit" value="Registrar" /></td></tr>
</table>
</form>
</body>
</html>
………………………………………………………………………………………………………………………………………………………
Insert
………………………………………………………………………………………………………………………………………………………..
<?php
include("Conexion.php";
$Id=$_POST['Id'];
$Nombre=$_POST['Nombre'];
$Apellido=$_POST['Apellido'];
$Direccion=$_POST['Direccion'];
$Tipo=$_POST['Tipo'];
mysql_query("insert into profe(idProfe, Nombre, Apellido, Direccion, Tipo_Semestre)
values ('$Id', '$Nombre', '$Apellido', '$Direccion', '$Tipo');", $conexion) or die("Error en meterlo";
echo "Alumno Metido con exito"
?>
………………………………………………………………………………………………………………………………………………….
Borrar. Esta en Form1
…………………………………………………………………………………………………………………………………………………
<!DOCTYPE HTML>
<head>
<meta http-equiv="content-type" content="text/html" />
<meta name="author" content="IIoZoII" />
<title>TrabajoBD</title>
</head>
<body>
<form action=" borra.php" method="post" name="form1">
<p align="center">
<input type="text" name="nombre"/>
<input type="submit" value="borrar" />
</p>
</form>
</body>
</html>
…………………………………………………………………………………………………………………………………………………………
Borrar.php Metodo
…………………………………………………………………………………………………………………………………………………………
<?php
include("Conexion.php";
$con = mysql_connect($host,$user,$pw) or die ("problemas al conectar";
mysql_select_db($db,$con) or die (" al conectar";
$nombre = $_POST['nombre'];
$hola= mysql_query("select idProfe from profe where Nombre = '$nombre' ",$con)
or die ("problemas al conectar:".mysql_error());
if ($reg= mysql_fetch_array($hola))
{
mysql_query("DELETE FROM profe where Nombre = '$nombre' ",$con)
or die ("problemas al conectar:".mysql_error());
echo "se han eliminado los datos";
} else
{
echo "problemas a eliminar";
}
?>
…………………………………………………………………………………………………………………………………………………………
Actualizar Esta en Form2.php “se crea un blog de notas es este nombre”
…………………………………………………………………………………………………………………………………………………………
<html>
<head>
<meta http-equiv="content-type" content="text/html" />
<meta name="author" content="IIoZoII" />
<title>TrabajoBD</title>
</head>
<body>
<form action=" update.php" method="post" name="form2">
<p align="center">
<input type="text" name="cviejo"/> <br></br>
<input type="text" name="cnuevo"/> <br></br>
<input type="submit" value="actualizar" />
<marquee direction="left" scrolldelay="300" scrollamount="12" behavior="scroll" loop="25" style="background-color:#7FFFD4;border:5px #00FF00 double;" id="Marquee1">
<font style="font-size:13px" color="#387AC8" face="Arial">Te Amo Me Enamore de Ti Con Solo Verte</font></marquee>
'<img src="1048765luffy.jpg" width="500" height="478" />'
</p>
</form>
</body>
</html>
Metodo de Actualizacion Update.php
<?php
include("Conexion.php";
$con = mysql_connect($host,$user,$pw) or die ("problemas al conectar server";
mysql_select_db($db,$con) or die (" al conectar bd";
mysql_query("update profe set Nombre = '$_POST[cnuevo]' where Nombre= '$_POST[cviejo]'",$con)
or die ("problemas al conectar:".mysql_error());
echo ("actualizacion correcta";
?>
………………………………………………………………………………………………………………………………………………………
<?php
$conexion = mysql_connect("localhost", "root", "";
mysql_select_db("escuela", $conexion);
$host="localhost";
$user="root";
$pw="";
$db="escuela"
?>
Consultar consultas.php
<html>
<head><title>Ejemplo de php</title></head>
<body>
<h2>Ejemplo de base de datos con php</h2>
<table border="1">
<tr>
<td>Idprofe</td><td>Nombre</td><td>Apellido</td><td>Direccion</td><td>Tipo semestre</td>
</tr>
<?php
include("Conexion.php";
$consulta=mysql_query("select * from profe;", $conexion);
while($reg=mysql_fetch_array($consulta))
{
echo "<tr><td>".$reg['idProfe']."</td><td>".$reg['Nombre']."</td><td>".$reg['Apellido']."</td><td>".$reg['Direccion']."</td><td>".$reg['Tipo_Semestre']."</td></tr>";
}
mysql_close($conexion);
?>
</table>
</body>
</html>
……………………………………………………………………………………………………………………………………………………..
Insertar
……………………………………………………………………………………………………………………………………………………..
<!DOCTYPE HTML>
<head>
<title>Untitled 1</title>
</head>
<form name="Formulario" method="Post" action="insert.php">
<body>
<table>
<tr><td>Inserta tu Id</td><td><input type="text" name="Id"/></td></tr>
<tr><td>Inserta Nombre</td><td><input type="text" name="Nombre" /></td></tr>
<tr><td>Insertar apellido</td><td><input type="text" name="Apellido" /></td></tr>
<tr><td>Inserte direccion</td><td><input type="text" name="Direccion" /></td></tr>
<tr><td>Inserte semestre</td><td><input type="text" name="Tipo" /></td></tr>
<tr><td></td><td><input type="submit" value="Registrar" /></td></tr>
</table>
</form>
</body>
</html>
………………………………………………………………………………………………………………………………………………………
Insert
………………………………………………………………………………………………………………………………………………………..
<?php
include("Conexion.php";
$Id=$_POST['Id'];
$Nombre=$_POST['Nombre'];
$Apellido=$_POST['Apellido'];
$Direccion=$_POST['Direccion'];
$Tipo=$_POST['Tipo'];
mysql_query("insert into profe(idProfe, Nombre, Apellido, Direccion, Tipo_Semestre)
values ('$Id', '$Nombre', '$Apellido', '$Direccion', '$Tipo');", $conexion) or die("Error en meterlo";
echo "Alumno Metido con exito"
?>
………………………………………………………………………………………………………………………………………………….
Borrar. Esta en Form1
…………………………………………………………………………………………………………………………………………………
<!DOCTYPE HTML>
<head>
<meta http-equiv="content-type" content="text/html" />
<meta name="author" content="IIoZoII" />
<title>TrabajoBD</title>
</head>
<body>
<form action=" borra.php" method="post" name="form1">
<p align="center">
<input type="text" name="nombre"/>
<input type="submit" value="borrar" />
</p>
</form>
</body>
</html>
…………………………………………………………………………………………………………………………………………………………
Borrar.php Metodo
…………………………………………………………………………………………………………………………………………………………
<?php
include("Conexion.php";
$con = mysql_connect($host,$user,$pw) or die ("problemas al conectar";
mysql_select_db($db,$con) or die (" al conectar";
$nombre = $_POST['nombre'];
$hola= mysql_query("select idProfe from profe where Nombre = '$nombre' ",$con)
or die ("problemas al conectar:".mysql_error());
if ($reg= mysql_fetch_array($hola))
{
mysql_query("DELETE FROM profe where Nombre = '$nombre' ",$con)
or die ("problemas al conectar:".mysql_error());
echo "se han eliminado los datos";
} else
{
echo "problemas a eliminar";
}
?>
…………………………………………………………………………………………………………………………………………………………
Actualizar Esta en Form2.php “se crea un blog de notas es este nombre”
…………………………………………………………………………………………………………………………………………………………
<html>
<head>
<meta http-equiv="content-type" content="text/html" />
<meta name="author" content="IIoZoII" />
<title>TrabajoBD</title>
</head>
<body>
<form action=" update.php" method="post" name="form2">
<p align="center">
<input type="text" name="cviejo"/> <br></br>
<input type="text" name="cnuevo"/> <br></br>
<input type="submit" value="actualizar" />
<marquee direction="left" scrolldelay="300" scrollamount="12" behavior="scroll" loop="25" style="background-color:#7FFFD4;border:5px #00FF00 double;" id="Marquee1">
<font style="font-size:13px" color="#387AC8" face="Arial">Te Amo Me Enamore de Ti Con Solo Verte</font></marquee>
'<img src="1048765luffy.jpg" width="500" height="478" />'
</p>
</form>
</body>
</html>
Metodo de Actualizacion Update.php
<?php
include("Conexion.php";
$con = mysql_connect($host,$user,$pw) or die ("problemas al conectar server";
mysql_select_db($db,$con) or die (" al conectar bd";
mysql_query("update profe set Nombre = '$_POST[cnuevo]' where Nombre= '$_POST[cviejo]'",$con)
or die ("problemas al conectar:".mysql_error());
echo ("actualizacion correcta";
?>