Last active
December 1, 2018 16:13
-
-
Save cesc1989/fb1aa1f2e525249462ce to your computer and use it in GitHub Desktop.
conectarse a la base de datos y actualizar varias filas mediante ciclo for
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 | |
//CONEXION A LA BASE DE DATOS | |
$username = "root"; | |
$password = "root"; | |
$hostname = "localhost"; | |
$link = mysql_connect($hostname, $username, $password); | |
if (!$link) { | |
die('Could not connect: ' . mysql_error()); | |
} | |
//SELECCIONAR BASE DE DATOS | |
$db = mysql_select_db("qhp", $link); | |
if (!$db) { | |
die ("No se puede usar la base de datos" . mysql_error()); | |
} | |
// HACER CONSULTA A LA TABLA DE AFILIADOS | |
for ($i=0; $i <140 ; $i++) { | |
$query = "UPDATE users SET typeofmembership = 'bronze' WHERE uid = $i"; | |
$result = mysql_query($query); | |
if (!$result){ | |
die("Consulta invalida " . mysql_error()); | |
} | |
} | |
// CERRAR LA CONEXION LUEGO DE HACER TODAS LAS OPERACIONES | |
mysql_close($link); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment