Last active
June 17, 2016 15:35
-
-
Save johnsi15/4980064 to your computer and use it in GitHub Desktop.
Este código realiza una conexión a una base de datos sqli con php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$bd = new mysqli("localhost","root","andrey15","agenda"); | |
if($bd->connect_errno){ | |
echo "Error en la conexion.."; | |
}else{ | |
echo "Conexion exitosa...<br>"; | |
echo $bd->host_info; | |
} | |
/* //para registrar datos.... | |
if(!$bd->query("INSERT INTO datos (nombre) VALUES ('John Andrey')")){ | |
echo "Error en el insert..."; | |
}else{ | |
echo "<br>Se registro correctamente"; | |
}*/ | |
$bd->query("DELETE FROM datos WHERE id='6'"); | |
$resultado = $bd->query("SELECT * FROM datos ORDER BY id ASC"); | |
if($resultado){ | |
echo "<br> Resulados del select"; | |
//$resultado->data_seek(0); | |
while($fila = $resultado->fetch_assoc()){ | |
echo " <br> id = ".$fila['id']."\n"; | |
echo " <br> nombre: ".$fila['nombre']; | |
} | |
$resultado->close(); | |
} | |
$bd->close(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment