Created
April 4, 2018 16:57
-
-
Save eamexicano/c1d4e8bb2f5244f6cbb7f38fb34a2abe to your computer and use it in GitHub Desktop.
clase.09/form.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
<!DOCTYPE html | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
</head> | |
<body> | |
<?php | |
// Abrir conexión | |
$conexion = new mysqli("localhost", "root", "", "tutoriales"); | |
// Guardar consulta en variable $query | |
$query = "SELECT * FROM usuarios"; | |
// Mandar consulta a MySQL | |
// Guardar resultados en variable $resultados | |
$resultados = $conexion->query($query); | |
// Mostrar resultados | |
while ($resultado = $resultados->fetch_array()) { | |
?> | |
<h1><?php echo $resultado["nombre"]; ?></h1> | |
<?php | |
} | |
/* | |
if (isset($_GET["q"])) { | |
echo $_GET["q"]; | |
} else { | |
// No hacer nada | |
} | |
*/ | |
?> | |
<form action="form.php.php" method="get"> | |
<input type="text" name="q"><br> | |
<input type="submit" value="Buscar"> | |
</form> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment