Skip to content

Instantly share code, notes, and snippets.

@cesc1989
Last active December 1, 2018 16:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cesc1989/fb1aa1f2e525249462ce to your computer and use it in GitHub Desktop.
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
<?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