-1

I am trying to get a value from column "odznak" in "users" tab for user "user01" and store it in variable $odznak (for searching in another tab.

$stmt = $conn->prepare("SELECT odznak FROM users WHERE username = 'user01'");
$stmt->execute();
$result = $stmt;
$odznak;

1 Answers1

2

You need to fetch the data (say into an associative array)

On the other hand, as a good practice, please use parameterized prepared statement in your select query

So, change to:

$stmt = $conn->prepare("SELECT odznak FROM users WHERE username = ?");
$stmt->bind_param("s", 'user01');
$stmt->execute();
$result = $stmt->get_result();
$row = $result->fetch_assoc();
$odznak=$row["odznak"];

Now, $odznak is the retrieved data

Ken Lee
  • 6,985
  • 3
  • 10
  • 29