Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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