Skip to content

Instantly share code, notes, and snippets.

  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save eamexicano/c1d4e8bb2f5244f6cbb7f38fb34a2abe to your computer and use it in GitHub Desktop.
clase.09/form.php
<!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