如何将任何内容从数据库添加到变量

时间:2019-04-23 11:22:00

标签: php sql database

我有2个表,第一个用户表,第二个表用于配置文件img。当有人要注册时,我想在用户表上的之后 ID上向用户配置文件img表发送用户信息。当用户信息完成时,在我需要将此信息发送到profileimg表之后,我需要从用户表中获取用户ID。 (我使用“ userid”,但不使用auto inc ...),当我尝试发送此代码时,我在profileimg userid上看到“ array”。我怎样才能做到这一点。

我无法从数据库获取信息

我正在使用mysqli。

else{
    $sql  = "INSERT INTO users (username, email, password, fname, sname, gender, birthday) VALUES (?, ?, ?, ?, ?, ?, ?)";
    $stmt = mysqli_stmt_init($conn);
    if (!mysqli_stmt_prepare($stmt, $sql)) {
        header("Location: ../kayitol.php?yanlis=sqlerror");
        exit();
    } else {
        $hashedPwd = password_hash($password, PASSWORD_DEFAULT);
        mysqli_stmt_bind_param($stmt, "sssssss", $username, $email, $hashedPwd, $fname, $sname, $gender, $birthday);
        mysqli_stmt_execute($stmt);
        **  ** myproblemstartsfromhere **  ** *
        if (!mysqli_stmt_prepare($stmt, $sql)) {
            header("Location: ../kayitol.php?yanlis=sqlerror");
            exit();
        } else {
            $sql    = "SELECT * FROM users WHERE username='$username' AND fname='$fname'";
            $result = mysqli_query($conn, $sql);
            if (mysqli_num_rows($result) > 0) {
                while ($row = mysqli_fetch_assoc($result));
                $userid = $row['idUsers'];
                $sql    = "INSERT INTO profileimg (userid, status) VALUES ('$userid', 1)";
                mysqli_query($conn, $sql);
                header("Location: ../kayitol.php?kayit=basarili");
                exit();
            }
        }
    }
}

1 个答案:

答案 0 :(得分:1)

更改此行:

library(tidyverse)
df <- data.frame(Sample = c(1,1,2,2,3,3),
                 Individual_class = c("A","B","A","B","A","B"),
                 Score_individual_class = c(10,20,50,80, 30,60),
                 Final_Score_Sample = c(80,80,90,90,120,120),
                 stringsAsFactors = FALSE)

收件人:

$userid = $row = ['idUsers'];