<?php

require("includes/check_auth_user.php");
require("includes/dbconnect.php");
include ('includes/function.php');

$zdb = $_SESSION["zdbyear_$dbname"];
mysqli_select_db($conn, $zdb);

$maindb = 'sufi';
$myyear = $_SESSION[$myyear];




$result = mysqli_query($conn, "SELECT * FROM $maindb order by srl") or die(mysqli_error($conn));
//print table($result);
$getnum = mysqli_num_rows($result);
//browse($getnum); 
$tname = '';
$mname = '';
while ($get = mysqli_fetch_array($result)) {
    $srl = $get["srl"];
    $name = $get["name"];

    if ($name != '') {
        $mname = $name;
    }else{
        $mname = $tname;
    }
    
//    browse($mname);
    mysqli_query($conn, "UPDATE $maindb set `name2`='$mname' where srl = '$srl'") or die(mysqli_error($conn));
//    $mname = $name;
}
browse("success");
?>
