如何动态命名数据框

时间:2019-06-07 04:20:49

标签: python sas

我有一个带有一些变量的数据。想要创建每个应具有一个变量的数据框,并且其名称应与包含该变量的名称相同。

说,数据框raw_data具有变量age,duration。创建一个数据年龄,该年龄应具有不同的年龄,数据持续时间应具有可变的持续时间。

if (isset($_POST['submit'])) {
include_once 'dbh.inc.php';
$first = mysqli_real_escape_string($conn, $_POST['first']);
$last = mysqli_real_escape_string($conn, $_POST['last']);
$email = mysqli_real_escape_string($conn, $_POST['email']);
$uid = mysqli_real_escape_string($conn, $_POST['uid']);
$pwd = mysqli_real_escape_string($conn, $_POST['pwd']);

$mysqli = new mysqli ('localhost', 'root', '', 'jordansworld');

if( $mysqli ->connect_error ) {
    die( 'Connect Error: ' . $mysqli->connect_errno . ': ' . $mysqli->connect_error );
}

$mysqli = "INSERT INTO user ( first, last, email, uid, pwd ) VALUES ( '{$mysqli->real_escape_string($_POST['first'])}' , ' {$mysqli->real_escape_string($_POST['last'])}' , '{$mysqli->real_escape_string($_POST['email'])}' , '{$mysqli->real_escape_string($_POST['uid'])}' , '{$mysqli->real_escape_string($_POST['pwd'])}'";
$insert = $mysqli->query($mysqli);

if ($insert) {
echo "Success! Row ID: {$mysqli->insert_id}";
} 
else 
{
die("Error: [$mysqli::errno] : [$mysqli::error]");
}
$mysqli->close();
}
/* Error Handlers */
/* Check empty fields */
if(empty($first) || empty($last)|| empty($email)|| empty($uid)|| 
empty($pwd)) 
{
header ("Location: ../signup.php?signup=empty");
exit();
}   
else 
 {
//Insert the user into the database
$mysqli = "INSERT INTO `users` (user_first, user_last, user_email, 
user_uid, user_pwd) VALUES ('$first' '$last', '$email', '$uid', 
'$pwd');";
            mysqli_query($conn, $mysqli);
            header("Location: ../signup.php?signup=success");
            exit();
}

此代码将覆盖数据框表。我想保留它们。

0 个答案:

没有答案