user2182192
user2182192

Reputation: 33

INSERT INTO 'table' that stored in a variable

How can i use my variable, which stores database table name in mysql query. Example:

$myTable = "customers";
$stmt = $this->db->prepare("INSERT INTO $myTable (smthg) VALUES ("value")");

I'm very new for mysql so sorry if this question is pretty stupid.

Upvotes: 0

Views: 55

Answers (1)

shofee
shofee

Reputation: 2129

$stmt = $this->db->prepare("INSERT INTO $myTable (smthg) VALUES ('$mytable')");

Upvotes: 1

Related Questions