lunes, 6 de abril de 2015

Copiando tablas PHP

<?php
 session_start();
 if(!isset($_SESSION['username'])) header("Location: index.html");
 include('../sistema/db.php');

 $sql = "SELECT id_variable, nombre_variable, variables_default FROM z_remi_variables_globales";
 $result = mysql_query($sql) or trigger_error(mysql_error());
 $IDS_VARIABLE = Array();
 $VALOR_VARIABLES = Array();
 
 while($row = mysql_fetch_array($result))
 {
  $IDS_VARIABLE[] = $row['id_variable'];
  $VALOR_VARIABLES[] = $row['variables_default'];
 }
 for ($i=0; $i < count($IDS_VARIABLE); $i++) { 
  $sql = "UPDATE z_remi_variables_globales 
  SET valor = '".$VALOR_VARIABLES[$i]."' WHERE id_variable = ".$IDS_VARIABLE[$i];
  mysql_query($sql);
 }
 header("Location: admin.php");
?>

valor copiara los valores de variables_default

No hay comentarios:

Publicar un comentario